Applyfilter code Problem

pablavo

Registered User.
Local time
Today, 02:47
Joined
Jun 28, 2007
Messages
189
Hi Folks

In my Main form I have several combo boxes to search for records. I'm having a problem with one of the Combos and I think it's because it's a number rather than txt. I'm using a CountryID from the Main table (with the Country field from the lookup table visible) and when I applyfilter I get

The following error has occured 2501 The applyfilter action was cancelled.

If I change the field source of the combo to a text field, and update the VBA it works.
Here's the code:

If Len(Me.cboCountry) > 0 Then
strCountry = Me.cboCountry
strwhere = "[CountryID]='" & strCountry & "'"
End If

I've even tried:

If Not IsNull(Me.cboCountry) Then
stWhere = "[CountryID]=" & Me.cboCountry & " And "
blnTrim = True
End If

and get a 3075 syntax error.

Does anyone know that I might be doing wrong? I'm still fairly new at VBA and all the help will be appreciated.
 
For number try this:

strwhere = "[CountryID]=" & [strCountry]
 
Hey, thanks alot MStef! that worked.
 

Users who are viewing this thread

Back
Top Bottom