General discussion

Locked

Inserting opt button values in SQL stmt

By venkata.perugu ·
How do I insert values from a option button (Depending which the user selects eg Y or N) into SQL statement?

Thanks a lot in advance

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Inserting opt button values in SQL stmt

by sl-campbell In reply to Inserting opt button valu ...

Assumming the option buttons in question are all on the same container:

1. You either need to make a loop to find out with option button was selected and assign the index to a variable:

Private m_iOptIndex As Integer

Private Sub GetOptionSelected()
Dim opt As OptionButton

For Each opt in optChoices

If optChoices.Value then
m_iOptIndex = optChoices.Index
Exit For
End If

Next opt
End Sub

OR on the Click event assign a form level variable to the index value:

Private m_iOptIndex As Integer
Private Sub optChoices_Click(Index As Integer)
m_iOptIndex = Index
End Sub

2. If you know that, for instance, option button #2 has been selected and the index is assigned to a variable, (m_iOptIndex) then you can use this in a SELECT statement, (assuming that a field exists which holds the option index to be used):

"SELECT * FROM myTable WHERE fldMyOptions=" & m_iOptIndex

Collapse -

Inserting opt button values in SQL stmt

by venkata.perugu In reply to Inserting opt button valu ...

The question was auto-closed by TechRepublic

Collapse -

Inserting opt button values in SQL stmt

by sl-campbell In reply to Inserting opt button valu ...
Collapse -

Inserting opt button values in SQL stmt

by venkata.perugu In reply to Inserting opt button valu ...

The question was auto-closed by TechRepublic

Collapse -

Inserting opt button values in SQL stmt

by venkata.perugu In reply to Inserting opt button valu ...

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums