Help With Search Form

G

Guest

Below is code I adopted from a named "gromit". Everything works perfectly
except for my "MRN" search. I had it working and I don't know why it stopped.
Could you please look at and see if you can see any problems. Thanks, Rob

'Check for MRN
If Me.lstSearch > 0 Then
varWhere = varWhere & "[MRN] = " & Me.MRN & " AND "
End If

Here's the entire function
**************************************************
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim varItem As Variant
Dim intIndex As Integer

varWhere = Null ' Main filter

' Check for LIKE First Name
If Me.FirstName > "" Then
varWhere = varWhere & "[FirstName] LIKE """ & Me.FirstName & "*""
AND "
End If

' Check for LIKE Last Name
If Me.LastName > "" Then
varWhere = varWhere & "[LastName] LIKE """ & Me.LastName & "*"" AND "
End If


'Check for MRN
If Me.lstSearch > 0 Then
varWhere = varWhere & "[MRN] = " & Me.MRN & " AND "
End If

' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE " & varWhere

' strip off last "AND" in the filter
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If

BuildFilter = varWhere

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top