Hayley Baxter
Registered User.
- Local time
- Today, 04:28
- Joined
- Dec 11, 2001
- Messages
- 1,607
Hi All
I am using QBF to search multiple fields then producing these results in a report this all works well. However the search items on the form are all combo boxes or text boxes, the latest addition to this form is a check box but the check box is not quite doing the job it is throwing up a data type mismatch error and as I am still not to good with vb thought some of you kind people can shed some light on this.
here is the code
Private Sub Search_Click()
Dim MyDatabase As Database
Dim MyQueryDef As QueryDef
Dim where As Variant
Set MyDatabase = CurrentDb()
' Delete the existing dynamic query; trap the error if the query does
' not exist.
If ObjectExists("Queries", "qryDynamic_QBF") = True Then
MyDatabase.QueryDefs.Delete "qryDynamic_QBF"
MyDatabase.QueryDefs.Refresh
End If
where = Null
where = where & " AND [ConID]= " + Me![ConID]
where = where & " AND [CategoryID]= " + Me![CategoryID]
where = where & " AND [DonotContactID]= " + Me![DoNotContactID]
where = where & " AND [ContactStatusID]= " + Me![ContactStatusID]
where = where & " AND [RequireProspectus]= " + Me![RequireProspectus]
If Not IsNull(Me![Meeting End Date]) Then
where = where & " AND [Meeting Date] between #" + _
Me![Meeting Start Date] + "# AND #" & Me![Meeting End Date] & "#"
Else
where = where & " AND [Meeting Date] >= #" + Me![Meeting Start Date] _
+ " #"
End If
Me.Form.Visible = False
Set MyQueryDef = MyDatabase.CreateQueryDef("qryDynamic_QBF", _
"Select * from tblProspects " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenReport "SearchResults", acViewPreview, "qryDynamic_QBF"
End Sub
The last line of the where is the checkbox named RequireProspectus.
Thanks to you all
Hay
I am using QBF to search multiple fields then producing these results in a report this all works well. However the search items on the form are all combo boxes or text boxes, the latest addition to this form is a check box but the check box is not quite doing the job it is throwing up a data type mismatch error and as I am still not to good with vb thought some of you kind people can shed some light on this.
here is the code
Private Sub Search_Click()
Dim MyDatabase As Database
Dim MyQueryDef As QueryDef
Dim where As Variant
Set MyDatabase = CurrentDb()
' Delete the existing dynamic query; trap the error if the query does
' not exist.
If ObjectExists("Queries", "qryDynamic_QBF") = True Then
MyDatabase.QueryDefs.Delete "qryDynamic_QBF"
MyDatabase.QueryDefs.Refresh
End If
where = Null
where = where & " AND [ConID]= " + Me![ConID]
where = where & " AND [CategoryID]= " + Me![CategoryID]
where = where & " AND [DonotContactID]= " + Me![DoNotContactID]
where = where & " AND [ContactStatusID]= " + Me![ContactStatusID]
where = where & " AND [RequireProspectus]= " + Me![RequireProspectus]
If Not IsNull(Me![Meeting End Date]) Then
where = where & " AND [Meeting Date] between #" + _
Me![Meeting Start Date] + "# AND #" & Me![Meeting End Date] & "#"
Else
where = where & " AND [Meeting Date] >= #" + Me![Meeting Start Date] _
+ " #"
End If
Me.Form.Visible = False
Set MyQueryDef = MyDatabase.CreateQueryDef("qryDynamic_QBF", _
"Select * from tblProspects " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenReport "SearchResults", acViewPreview, "qryDynamic_QBF"
End Sub
The last line of the where is the checkbox named RequireProspectus.
Thanks to you all
Hay