Using wild-card in wherecondition

sukhi

Registered User.
Local time
Today, 21:28
Joined
May 1, 2004
Messages
10
Hi,

Can I use wild-card in the OpenForm's WhereCondition? I've tried this but doesn't work:

DoCmd.OpenForm("Form_Name", , , "First_Name = 'Alan*'")

I want the form to show all the records having "First_Name" starting with "Alan"
please help!

Thanks in advance.
 
Try...

"First_Name Like 'Alan*'"
 
RichO said:
Try...

"First_Name Like 'Alan*'"
Thanks for the reply RichO, but i tried this and not working :(
there must be an SQL statement, but i dont know where and how to fit in WhereCondition
 
You're saying it doesn't work. What exactly does it do when your form opens? Do you get an error, a blank form, or the wrong record(s)?

I tried it out and it worked perfectly. However, VBA did not like the syntax of this line, namely the parenthesis.

DoCmd.OpenForm("Form_Name", , , "First_Name = 'Alan*'")

Try it this way:

DoCmd.OpenForm "Form_Name", , , "First_Name Like 'Alan*'"

If that still doesn't work you could also try:

DoCmd.OpenForm "Form_Name", , , "Left([First_Name], 4) = 'Alan'"
 
RichO said:
You're saying it doesn't work. What exactly does it do when your form opens? Do you get an error, a blank form, or the wrong record(s)?

I tried it out and it worked perfectly. However, VBA did not like the syntax of this line, namely the parenthesis.

DoCmd.OpenForm("Form_Name", , , "First_Name = 'Alan*'")

Try it this way:

DoCmd.OpenForm "Form_Name", , , "First_Name Like 'Alan*'"

If that still doesn't work you could also try:

DoCmd.OpenForm "Form_Name", , , "Left([First_Name], 4) = 'Alan'"
Yes you are right, i removed parenthesis and now its working :D ..thanks a lot
 

Users who are viewing this thread

Back
Top Bottom