Using 'like' on a user prompt

R

RicDon

I want to prompt the user for a value to use to filter a form. Here is my
command with the WhereCondition:

docmd.OpenForm "test", acNormal, , "LastName=[Enter a Last Name]"

I want to use the WhereCondition as a "LIKE" criteria. Variations on the
WhereCondition itself that I've tried include various combinations of

LastName LIKE %...%
LastName LIKE *...*
LastName LIKE [%...%]
LastName LIKE [*...*]

You get the idea...

No luck so far. Any thoughts?
 
J

John W. Vinson

I want to prompt the user for a value to use to filter a form. Here is my
command with the WhereCondition:

docmd.OpenForm "test", acNormal, , "LastName=[Enter a Last Name]"

I want to use the WhereCondition as a "LIKE" criteria. Variations on the
WhereCondition itself that I've tried include various combinations of

LastName LIKE %...%
LastName LIKE *...*
LastName LIKE [%...%]
LastName LIKE [*...*]

You get the idea...

No luck so far. Any thoughts?

LastName LIKE "*" & [Enter a last name, or part of one:] & "*"
 
D

Dirk Goldgar

RicDon said:
I want to prompt the user for a value to use to filter a form. Here is my
command with the WhereCondition:

docmd.OpenForm "test", acNormal, , "LastName=[Enter a Last Name]"

I want to use the WhereCondition as a "LIKE" criteria. Variations on the
WhereCondition itself that I've tried include various combinations of

LastName LIKE %...%
LastName LIKE *...*
LastName LIKE [%...%]
LastName LIKE [*...*]

You get the idea...

No luck so far. Any thoughts?


Try:

Docmd.OpenForm "test", acNormal, _
WhereCondition:="LastName Like '*' & [Enter a Last Name] & '*'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top