UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Filter For Using Like...., Any Version    
 
   
jimbofoxman
post Jun 1 2020, 11:36 AM
Post#1



Posts: 423
Joined: 4-April 08



This has to be a syntax issue. I am running this code, trying to add the 3rd if statement.......for the CrewFilter. CrewFilter is a combo box with the 2nd column (only 2 text characters) as the bound column. The list is hard coded in, not fed from a table. After update it says Missing Operator in Query Expression. I put "Msgbox strwhere" to see what it was returning, which to me seems fine.

So say I select the option that has the second column = VA. So it would return [InstallCrew] = Like "VA*"

I'm sure I am missing something simple! What am I over looking? Thanks

CODE
    Dim strWhere As String

    'Make string
    If Nz(Me.FromDate, "") <> "" Then
        strWhere = strWhere & "[EID] >= #" & Me.FromDate & "# AND "
    End If

    If Nz(Me.EndDate, "") <> "" Then
        strWhere = strWhere & "[EID] <= #" & Me.EndDate & "# AND "
    End If
    
    If Nz(Me.CrewFilter, "") <> "" Then
        strWhere = strWhere & "[InstallCrew] = Like """ & Me.CrewFilter & "*"" And "
    End If

    'Apply filter
    If strWhere <> "" Then
        strWhere = Left(strWhere, Len(strWhere) - 5) 'Remove the extra AND
        'MsgBox strWhere
        'Exit Sub
        Me.Filter = strWhere
        Me.FilterOn = True
    Else
        Me.Filter = ""
        Me.FilterOn = False
    End If
Go to the top of the page
 
projecttoday
post Jun 1 2020, 11:59 AM
Post#2


UtterAccess VIP
Posts: 12,376
Joined: 10-February 04
From: South Charleston, WV


In SQL you use = or Like, but not both.

--------------------
Robert Crouser
Go to the top of the page
 
jimbofoxman
post Jun 1 2020, 12:09 PM
Post#3



Posts: 423
Joined: 4-April 08



Geesh, knew it was something stupid. dunce.gif

Thanks!
Go to the top of the page
 
projecttoday
post Jun 1 2020, 12:25 PM
Post#4


UtterAccess VIP
Posts: 12,376
Joined: 10-February 04
From: South Charleston, WV


thumbup.gif

--------------------
Robert Crouser
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    4th July 2020 - 01:27 PM