how to put NOT LIKE in vba

basilyos

Registered User.
Local time
Today, 00:18
Joined
Jan 13, 2014
Messages
256
i want to bring all the records that are not like [sometext]

i wrote this code

If p_foreign <> "" Then
p_SQL_criteria = "[Nationality]" & " NOT LIKE '" & p_foreign & "'"
End If

but it's not working
 
The string looks OK so what are you doing with p_SQL_criteria once you have calculated it? You need to apply it to a form filter or the where parameter of docmd.openquery/form/report
 
the other possibility is you haven't assigned a value to p_foreign - suggest change to

Code:
If nz(p_foreign) <> "" Then
....
 
i want to bring all the records that are not like [sometext]

i wrote this code

If p_foreign <> "" Then
p_SQL_criteria = "[Nationality]" & " NOT LIKE '*" & p_foreign & "*'"
End If

but it's not working

You are missng the wildcards:banghead:
 

Users who are viewing this thread

Back
Top Bottom