Query Reference "or"

M

meyerryang

I have a query that brings in data based on the Username. If the record says
"Bob Smith" in the user field then all of Bob Smith's records come up. I am
limited on my design due to an Oracle backend. I want to have the Username
say "Bob Smith" or "Bill Jones" and bring up a combined list of either Users
records. The problem I am having is whenever I update the username on the
form to have more than one user it doesn't recognize the text when it is
linked to the query (ex: "Bob Smith" or "Bill Jones" =forms![My
Form]![Username]). It works within the query but not when it is linked to
the textbox (Username) that says "Bob Smith" or "Bill Jones". How else can I
refer to the "or" to get it to recognize that there are two usernames.

Please do not suggest design restructure, this has an oracle backend and
these tables are not related in anyway. Thanks in advance.
 
R

Roger Carlson

The problem here is what you think is happening is not happening. You see
"Bob Smith" or "Bill Jones" in the Query builder when you run the query.
But in SQL, it looks like this

[Username] = "Bob Smith" or [Username] = "Bill Jones".

So when you reference a text box with "Bob Smith" or "Bill Jones" in it,
what SQL sees is

[Username] = "Bob Smith or Bill Jones"

and you don't have a user named "Bob Smith or Bill Jones".

What you are going to have to do is parse out your textbox values into two
separate expressions.

On my website (www.rogersaccesslibrary.com), are several small Access
database samples (CreateQueries2-2k.mdb, CreateQueries4-2k.mdb,
CreateQueries5-2k.mdb, CreateQueryFields2k.mdb) which illustrate several
variations on how to do this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 

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