Hello all,
I am new to the forum and an Access novice. Not too long ago, I stumbled on to a Dynamic Multi Search form on this site and have been tailoring it to my organization's directory of contacts. Everything was going good until I was asked to include a search by groups to which each individual may belong. The data in the table is contained in Yes/No check boxes for around 30 different groups. I am hoping to add a combo box to the Dynamic Search as a means to pull up individuals in any 1 category.
Below are two attempts at what I thought might work, however, neither performs any filtering. Any and all help is greatly appreciated.
I am new to the forum and an Access novice. Not too long ago, I stumbled on to a Dynamic Multi Search form on this site and have been tailoring it to my organization's directory of contacts. Everything was going good until I was asked to include a search by groups to which each individual may belong. The data in the table is contained in Yes/No check boxes for around 30 different groups. I am hoping to add a combo box to the Dynamic Search as a means to pull up individuals in any 1 category.
Below are two attempts at what I thought might work, however, neither performs any filtering. Any and all help is greatly appreciated.
Code:
Private Sub Groupbox_Change()
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryGroup")
strSQL = "Select Snap_Contact_master.* FROM SNAP_Contact_master"
Select Case Me.Groupbox
Case "cboUsed" strSQL = "where SNAP_Contact_master.groupbox.Text & " = vbTrue
End Select
Me.SearchResults = Me.SearchResults.ItemData(1) Me.SearchResults.SetFocus
DoCmd.Requery
End Sub
Code:
Private Sub Groupbox_Change()
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryGroup")
sqlQry = "Select SNAP_Contact_Master.*"
Select Case Me.Groupbox
Case "Urban 14"
sqlQry = Me.Groupbox.SelText & " WHERE Urban14 = True"
Case "Claims"
sqlQry = sqlQry & " WHERE Claims = vbtrue"
Case "EBT"
sqlQry = sqlQry & " WHERE EBT = vbtrue"
Case Else
sqlQry = sqlQry & " WHERE Urban14 = vbtrue Or Claims = vbtrue Or EBT = vbtrue"
End Select
Me.SearchResults = Me.SearchResults.ItemData(1) Me.SearchResults.SetFocus
DoCmd.Requery
End Sub