Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Choice Option Group - Possible?

Status
Not open for further replies.

osx99

Technical User
Apr 9, 2003
250
GB
Is it possible to produce a multiple choice option group? If not is there a easy way to replicate one?

Many thankx,
Osx
 
Hi

Just have a series of option buttons, with a border drawn around them so it looks like an option group, but of course if you can select multiple options, then it will not return a single value and you will have to examine each option button

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Option groups allow one selection only, but you I've gotten around it by generating a dynamic sql statement on the fly - maybe you can adapt this to your needs....

Function opt_sql()
Dim opt As String, sqlstr As String, X As Byte, z As Long, STATUS As String, altype As String
STATUS = " AND YourTable.Status = '" & Forms!YourForm!cboStatus & "'"
altype = " AND YourTable.Type LIKE '" & Forms!YourForm!cboType & "'"

opt_sql = ""
For X = 1 To 18
opt = Me("OptionShip" & X)
If Me("OptionShip" & X) = -1 Then
Select Case X
Case Is = 1
sqlstr = "YourTable.[opt1]=-1" & STATUS & altype
Case Is = 2
sqlstr = "YourTable.[opt2]=-1" & STATUS & altype
Case Is = 3
sqlstr = "YourTable.[opt3]=-1" & STATUS & altype
Case Is = 4
sqlstr = "YourTable.[opt4]=-1" & STATUS & altype
Case Is = 5
sqlstr = "YourTable.[opt5]=-1" & STATUS & altype
Case Is = 6
sqlstr = "YourTable.[opt6]=-1" & STATUS & altype
Case Is = 7
sqlstr = "YourTable.[opt7]=-1" & STATUS & altype
Case Is = 8
sqlstr = "YourTable.[opt8]=-1" & STATUS & altype
Case Is = 9
sqlstr = "YourTable.[opt9]=-1" & STATUS & altype
Case Is = 10
sqlstr = "YourTable.[opt10]=-1" & STATUS & altype
Case Is = 11
sqlstr = "YourTable.[opt11]=-1" & STATUS & altype
Case Is = 12
sqlstr = "YourTable.[opt12]=-1" & STATUS & altype
Case Is = 13
sqlstr = "YourTable.[opt13]=-1" & STATUS & altype
Case Is = 14
sqlstr = "YourTable.[opt14]=-1" & STATUS & altype
Case Is = 15
sqlstr = "YourTable.[opt15]=-1" & STATUS & altype
Case Is = 16
sqlstr = "YourTable.[opt16]=-1" & STATUS & altype
Case Is = 17
sqlstr = "YourTable.[opt17]=-1" & STATUS & altype
Case Is = 18
sqlstr = "YourTable.[opt18]=-1" & STATUS & altype
End Select
z = Len(opt_sql)
If (Not IsNull(opt_sql) Or opt_sql = "") And Len(opt_sql) > 8 Then
opt_sql = opt_sql & " OR " & sqlstr
Else
opt_sql = sqlstr
End If
End If
Next X
End Function



This is then called by another dynamic sql statement using a multi select listbox:

Dim ctlSource As Control
Dim strItems As String
Dim intCurrentRow As Integer

Set ctlSource = Forms!YourForm!lstMultiSelectListbox

For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strItems = strItems & ctlSource.Column(1, intCurrentRow) & ", "
End If
Next intCurrentRow

sql = "SELECT " & Left(strItems, Len(strItems) - 2) & " FROM YourTable"
sql = sql & " WHERE " & opt_sql
sql = sql & " ORDER BY YourTable.ControlNumber;"




Hope this helps
 
Should mention that the examples I posted make use of radio buttons grouped together (similar to what Ken suggested)
 
the only was i can think of in rder to have just one field which stores the data, is as follows:

1. Design the table = "table 1".
2. Design a second table with the 3 (u can have as many as u like) options, and then save it.
3. In table 1 click on the filed where you wish for the option to be saved and in the properties section select lookup.
4. select the second table.
5. follow the onscreen prompts.
6. Thats it.

Hope this of help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top