Re: Using combo box to search form
- From: "Jeff Boyce" <nonsense@xxxxxxxxxxxx>
- Date: Mon, 23 Apr 2007 11:48:38 -0700
Daniel
Have you tried building one of your WHERE strings and using that in a query?
You can open a new query in design view, switch to SQL view, and paste (or
type) in a SQL string, then run the query.
I suspect you may be having an issue with too many "AND"s...
Regards
Jeff Boyce
Microsoft Office/Access MVP
"Daniel" <Daniel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:18E6F713-EF8A-4408-89CC-499992397D12@xxxxxxxxxxxxxxxx
Hi, I am creating a search area in the Header section of my form to
display
the results in the Detail section. The code I have so far is below. It
isn't really working properly, so I am hoping someone can look at it and
see
why.
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim strA As String
Dim strB As String
Dim lngLen As Long
If Me.cboLevel = "A" Then
strA = "A"
strWhere = strWhere & "([Level] = strA ) AND "
ElseIf Me.cboLevel = "B" Then
strB = "B"
strWhere = strWhere & "([Level] = strB) AND "
Else
strWhere = strWhere & "([Level] = FALSE) AND "
End If
If Not IsNull(Me.cboCompanyName) Then
strWhere = strWhere & "([CompanyName] = TRUE) AND "
Else
strWhere = strWhere & "([CompanyName] = False) AND "
End If
If Not IsNull(Me.cboCountry) Then
strWhere = strWhere & "([Country] = TRUE) AND "
Else
strWhere = strWhere & "([Country] = FALSE) AND "
End If
If Not IsNull(Me.cboArch) Then
strWhere = strWhere & "([ArchFixtures] = TRUE) AND "
Else
strWhere = strWhere & "([ArchFixtures] = FALSE) AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
.
- Follow-Ups:
- Re: Using combo box to search form
- From: Daniel
- Re: Using combo box to search form
- Prev by Date: Re: Create a Constants table in VB code
- Next by Date: Re: Using combo box to search form
- Previous by thread: Re: Update Text box
- Next by thread: Re: Using combo box to search form
- Index(es):
Relevant Pages
|
Loading