How to set 'Contains' in a Filter Statement?

MarkA70

Registered User.
Local time
Today, 12:10
Joined
Jan 30, 2016
Messages
43
I can set the doCmd.Open form filter programatically with the Like statement, using Contains I get a syntax error. What am I doing wrong,
this works with the Like modifier DoCmd.OpenForm "frm_Members_1", acNormal, , "Last Like Forms![frm_Hidden]![Hidden_txt0]", but this DOES NOT work with Contains DoCmd.OpenForm "frm_Members_1", acNormal, , "Last Contains Forms![frm_Hidden]![Hidden_txt0]":banghead:
 
"[Last] Like '*" & [frm_Hidden]![Hidden_txt0] & "*'"
 
Thanks arnelgp but entering that code with the LIKE replaced by CONTAINS results in the error 'Compile Error, Expected End of Statement.
 
No use the LIKE - the wildcards ( * ) make it behave in the same fashion as a CONTAINS.
 
try adding adding nz and another comma:
DoCmd.OpenForm "frm_Members_1", acNormal, , , "[Last] Like '*" & Nz(Forms![frm_Hidden]![Hidden_txt0], "") & "*'"
 
THANKS ALL!!!!!! I was confused in thinking there was a 'Contains' modifier for the doCmd filter. Of course, as y'all know, there is not. It is how variable for the Like modifier is configured. Found a guide on line for the query parameters, now when the Contains Text box on my main form is used, I store the value entered there as *+Value Entered+* and the the code DoCmd.OpenForm "frm_Members_1", acNormal, , "Last Like Forms![frm_Hidden]![Hidden_txt0] " works perfectly. Been awhile since I programmed VBA as you can tell. Again, THANKS for the Help!!
 

Users who are viewing this thread

Back
Top Bottom