G
Gen
Hi,
I have created a form (MainForm) that does not have any recordsource. There
is a subform in it that displays the records in a query. On the main form
there are several text boxes and combo boxes that I can use to enter criteria
to search for specific records to display in the main form. The form design
was downloaded from:
http://www.access-programmers.co.uk/forums/archive/index.php/t-99353.html.
For some reason when I adapted this design to my form, it doesn't work
properly. Specifically, when I press the search button, nothing happens - no
searching, no error messages. And I can't figure out why!!!!!! Here is a
sample of my code:
1. I set the record source property of the subform to the Function BuildFilter
Private Sub btnSearch_Click()
' Update the record source
Me.FRM_Find SubForm.Form.RecordSource = "SELECT * FROM QRY_Find WHERE "
& BuildFilter
' Requery the subform
Me.FRM_Find SubForm.Requery
End Sub
2. I create build filter
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim intIndex As Integer
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yy\#"
varWhere = Null ' Main filter
' Check for Assay Type
If Not IsNull(Me.cboAssay) Then
varWhere = varWhere & "[Assay] = " & Me.cboAssay & " AND "
End If
etc..... for all the boxes, then
' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
Else
lngLen = Len(varWhere) - 5
If lngLen <= 0 Then
MsgBox "No Criteria", vbInformation, "Nothing to do."
Else
varWhere = Left$(varWhere, lngLen)
End If
End If
BuildFilter = varWhere
End Function
What am I missing?!??!?!?! Its driving me nuts! Any help is appreciated
I have created a form (MainForm) that does not have any recordsource. There
is a subform in it that displays the records in a query. On the main form
there are several text boxes and combo boxes that I can use to enter criteria
to search for specific records to display in the main form. The form design
was downloaded from:
http://www.access-programmers.co.uk/forums/archive/index.php/t-99353.html.
For some reason when I adapted this design to my form, it doesn't work
properly. Specifically, when I press the search button, nothing happens - no
searching, no error messages. And I can't figure out why!!!!!! Here is a
sample of my code:
1. I set the record source property of the subform to the Function BuildFilter
Private Sub btnSearch_Click()
' Update the record source
Me.FRM_Find SubForm.Form.RecordSource = "SELECT * FROM QRY_Find WHERE "
& BuildFilter
' Requery the subform
Me.FRM_Find SubForm.Requery
End Sub
2. I create build filter
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim intIndex As Integer
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yy\#"
varWhere = Null ' Main filter
' Check for Assay Type
If Not IsNull(Me.cboAssay) Then
varWhere = varWhere & "[Assay] = " & Me.cboAssay & " AND "
End If
etc..... for all the boxes, then
' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
Else
lngLen = Len(varWhere) - 5
If lngLen <= 0 Then
MsgBox "No Criteria", vbInformation, "Nothing to do."
Else
varWhere = Left$(varWhere, lngLen)
End If
End If
BuildFilter = varWhere
End Function
What am I missing?!??!?!?! Its driving me nuts! Any help is appreciated