How do I get the right records for the combo box?

G

George Applegate

I have a form. On the form the user enters a "location". I want to
then, based on the value they enter, display the possible names they
can enter for the "user" field. Each user is associated with a
location.

How do I do this? Do I need to do something on the "location" form
field or do I put something in the "user" field???

I have a combo box for the user and it displays names, but the problem
is, it doesn't display the users associated with the "location" form
field.

Any ideas of what I need to do? on my combo user field I say
something like "Select User, Name, Address, WHERE Table.User.location
= [Forms]![Formname]![Location]"

Obviously I have something wacky...I would be VERY GRATEFUL if someone
could post some sample code where I can put a value in a text box and
then have a combo box display values based on what is entered into the
text box...

thanks,
ga

George Applegate
(e-mail address removed)
 
K

Klatuu

This part looks a bit suspicious:
Table.User.location

There should not be 3 separate idendifiers. Is the location field in a
table called User along with the other fields?
Also, you don't have a FROM clause in your query. My guess is your combo
is not showing anything. Also, assuming the location control you are
referencing is on the same form as the combo box, you should be able to do
it something like this:
SELECT User, [Name], Address FROM User WHERE location = Me.location;

There are other problems. Notice I put Name in brackets. Name is a
reserved word that should not be used as a name in Access. You actually
should use something more descriptive like UserName, EmployeeName, etc. It
is unusual and may cause problems if you have a field name like User that is
in a table named User.

And, to get the combo to show only those names for the location, you have to
requery the combo in the After Update event of the location text box.

"Select User, Name, Address, WHERE Table.User.location
= [Forms]![Formname]![Location]"
 

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