Wild card in query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table I am trying to query I want to return all rows with H* and
convert them to other text in my column, here is the query, can't figure out
what I am doing wrong.
iif([field]="h*","handy",iif([field]="t*","tell",null)) I have tried it with
h* no asteriks but it doesn't work. Is this possible to do?
 
Use the Like operator with wildcards:
IIf([Field] Like "h*", ...

If you are trying to replace the leading h with a leading t, you would need
to use the Criteria of:
Like "h*"
and in the Update row of the query:
"t" & Mid([Field], 2)

The Replace() function might also be useful.
 
Allen I misread your reply, so if you will allow me to expand on your first
answer.

IIF([field]Like "h*","handy",IIF ([field] LIKE "t*","tell",null))

Allen Browne said:
Use the Like operator with wildcards:
IIf([Field] Like "h*", ...

If you are trying to replace the leading h with a leading t, you would
need to use the Criteria of:
Like "h*"
and in the Update row of the query:
"t" & Mid([Field], 2)

The Replace() function might also be useful.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Akrt48 said:
I have a table I am trying to query I want to return all rows with H* and
convert them to other text in my column, here is the query, can't figure
out
what I am doing wrong.
iif([field]="h*","handy",iif([field]="t*","tell",null)) I have tried it
with
h* no asteriks but it doesn't work. Is this possible to do?
 
Thank you Allen worked perfectly!

Allen Browne said:
Use the Like operator with wildcards:
IIf([Field] Like "h*", ...

If you are trying to replace the leading h with a leading t, you would need
to use the Criteria of:
Like "h*"
and in the Update row of the query:
"t" & Mid([Field], 2)

The Replace() function might also be useful.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Akrt48 said:
I have a table I am trying to query I want to return all rows with H* and
convert them to other text in my column, here is the query, can't figure
out
what I am doing wrong.
iif([field]="h*","handy",iif([field]="t*","tell",null)) I have tried it
with
h* no asteriks but it doesn't work. Is this possible to do?
 

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

Back
Top