G
Ghagg
From a previous effort using Cascading List Boxes, i was able to
subsequently run a command button for the first listbox which then lists the
results in a query selection in datasheet view.
See following code. Now i would like to run a similar query that shows the
results of a combobox selection in a datasheet view. Thanks for your help
Best regards,
Ghagg
Private Sub cmdClass_Click()
Dim Q As QueryDef, db As Database
Dim Criteria As String
Dim ctl As Control
Dim Itm As Variant
' Build a list of the selections.
Set ctl = Me![ListClass1]
For Each Itm In ctl.ItemsSelected
If Len(Criteria) = 0 Then
Criteria = Chr(34) & ctl.ItemData(Itm) & Chr(34)
Else
Criteria = Criteria & "," & Chr(34) & ctl.ItemData(Itm) _
& Chr(34)
End If
Next Itm
If Len(Criteria) = 0 Then
Itm = MsgBox("You must select one or more items in the" & _
" list box!", 0, "No Selection Made")
Exit Sub
End If
' Modify the Query.
Set db = CurrentDb()
Set Q = db.QueryDefs("qryMultiSelectClass")
Q.SQL = "Select * From tblBuncombeWebprcls Where [ClassName] In(" & Criteria
& _
");"
Q.Close
' Run the query.
DoCmd.OpenQuery "qryMultiSelectClass"
End Sub
subsequently run a command button for the first listbox which then lists the
results in a query selection in datasheet view.
See following code. Now i would like to run a similar query that shows the
results of a combobox selection in a datasheet view. Thanks for your help
Best regards,
Ghagg
Private Sub cmdClass_Click()
Dim Q As QueryDef, db As Database
Dim Criteria As String
Dim ctl As Control
Dim Itm As Variant
' Build a list of the selections.
Set ctl = Me![ListClass1]
For Each Itm In ctl.ItemsSelected
If Len(Criteria) = 0 Then
Criteria = Chr(34) & ctl.ItemData(Itm) & Chr(34)
Else
Criteria = Criteria & "," & Chr(34) & ctl.ItemData(Itm) _
& Chr(34)
End If
Next Itm
If Len(Criteria) = 0 Then
Itm = MsgBox("You must select one or more items in the" & _
" list box!", 0, "No Selection Made")
Exit Sub
End If
' Modify the Query.
Set db = CurrentDb()
Set Q = db.QueryDefs("qryMultiSelectClass")
Q.SQL = "Select * From tblBuncombeWebprcls Where [ClassName] In(" & Criteria
& _
");"
Q.Close
' Run the query.
DoCmd.OpenQuery "qryMultiSelectClass"
End Sub