Dlookup with 'like' operator and wildcards

M

Michael Streeks

Hi,
I am trying to use the dlookup function in an event to
return the value of an id column where part of the value
in another column(same row) matches the value of a textbox.

The database is sequel with access front end.

The problem I seem to be having is that access basic feels
bad when I use %'s in my code. Depending on where i place
the delimiters I get several different errors. It also
seems that single quotes do not work at all where %'s are
on the same line.

this works:
ID = DLookup("[man_id]", "tblmanufact", "[man_name] = '" _
& Me!txtFindPart & "'")

this doesn't:
ID = DLookup("[man_id]", "[tblmanufact]", "[man_name] _
= ""%" & Me.txtFindPart.Value & "%""")

(Returns runtime error: "Invalid column name '%cdc%'."
where cdc is the value of me!txtfindpart

Another example(not dlookup, but i had %,' trouble):
works:
me.fiter = "([part_description] Like ""%" & _
Me!txtFindPart & "%"")"

works not:
me.filter = "([part_description] Like '"%" & _
Me!txtFindPart & "%"')"


I have been working with access for about a week and i'm
fairly certain i don't know what i'm doing. Any help will
be greatly appreciated.

Michael
 

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