elevins
Technical User
- Jan 24, 2005
- 18
Can anyone help me?
I am using Dynamic Query, it is run when a click a command button. All the text boxes are working fine but I would like to use check boxes to search also. I am having trouble finding any info on how to search using a check box.
Here is an example of what code I am using:
Private Sub cmdRunQuery_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb()
On Error Resume Next
db.querydefs.Delete ("Dynamic_Query")
On Error GoTo 0
where = Null
where = where & " AND [Inventory]like '" + Me![Inventory] + "*'"
where = where & " AND [SerialNum]like '" + Me![SerialNum] + "*'"
where = where & " AND [Description]like '" + Me![Description] + "*'"
where = where & " AND [Mfg]like '" + Me![Mfg] + "'"
where = where & " AND [ModelNum]like '" + Me![ModelNum] + "*'"
where = where & " AND [Cost]like '" + Me![Cost] + "'"
where = where & " AND [CaseNum]like '" + Me![CaseNum] + "*'"
where = where & " AND [Remarks]like '" + Me![Remarks] + "*'"
where = where & " AND [Date]like '" + Me![Date] + "*'"
' Where = Where & " AND [Stored]= '" + Me![Stored] + "'" ' this is the checkbox - yes/no there will be three more check boxes
Set QD = db.CreateQueryDef("Dynamic_Query", _
"Select * from SearchQueryBase " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenQuery "Dynamic_Query"
End Sub
I am using Dynamic Query, it is run when a click a command button. All the text boxes are working fine but I would like to use check boxes to search also. I am having trouble finding any info on how to search using a check box.
Here is an example of what code I am using:
Private Sub cmdRunQuery_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb()
On Error Resume Next
db.querydefs.Delete ("Dynamic_Query")
On Error GoTo 0
where = Null
where = where & " AND [Inventory]like '" + Me![Inventory] + "*'"
where = where & " AND [SerialNum]like '" + Me![SerialNum] + "*'"
where = where & " AND [Description]like '" + Me![Description] + "*'"
where = where & " AND [Mfg]like '" + Me![Mfg] + "'"
where = where & " AND [ModelNum]like '" + Me![ModelNum] + "*'"
where = where & " AND [Cost]like '" + Me![Cost] + "'"
where = where & " AND [CaseNum]like '" + Me![CaseNum] + "*'"
where = where & " AND [Remarks]like '" + Me![Remarks] + "*'"
where = where & " AND [Date]like '" + Me![Date] + "*'"
' Where = Where & " AND [Stored]= '" + Me![Stored] + "'" ' this is the checkbox - yes/no there will be three more check boxes
Set QD = db.CreateQueryDef("Dynamic_Query", _
"Select * from SearchQueryBase " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenQuery "Dynamic_Query"
End Sub