Query using a combo box

  • Thread starter Thread starter Robert Ross
  • Start date Start date
R

Robert Ross

I'm trying to construct a query that calls to a combo
box. When I select records from the combo box, the query
doesn't seem to find them. Here is the query SQL:

SELECT Stats.UserID
FROM Stats
WHERE (((Stats.UserID)=[Forms]![Reports Switchboard]!
[UserIDCombo]));

The form it calls to has a combo box named UserIDCombo
without any control source set (tried setting it, didn't
work), Row source as:
SELECT AgentsByTeam.UserID, AgentsByTeam.NAME FROM
AgentsByTeam;

2 columns (1st bound - UserID), Multi Select set to
extended.

What am I missing? Any help would be greatly appreciated!
 
What are you doing that tells Access to run this query? Is the userid
field text or numeric?

Seems to me that if you already know the USERID from the combo box,
you don't have a necessity to run a select query that only returns the
UserID.

--
HTH

Dale Fye


I'm trying to construct a query that calls to a combo
box. When I select records from the combo box, the query
doesn't seem to find them. Here is the query SQL:

SELECT Stats.UserID
FROM Stats
WHERE (((Stats.UserID)=[Forms]![Reports Switchboard]!
[UserIDCombo]));

The form it calls to has a combo box named UserIDCombo
without any control source set (tried setting it, didn't
work), Row source as:
SELECT AgentsByTeam.UserID, AgentsByTeam.NAME FROM
AgentsByTeam;

2 columns (1st bound - UserID), Multi Select set to
extended.

What am I missing? Any help would be greatly appreciated!
 
The system is set up to show all of the employees assigned
to a supervisor (that query populates the combo box). The
supervisor can then choose any number of those users to
run a query on. The query is manually triggered and
should pull only the selected employees from the list of
employees assigned to the supervisor.

As for only returning the UserID, I'm using that as a
test, it will return much more than that.

Does this help explain it?

THX!
 
Not really. Since you can only select one name at a time from a combo
box, does that mean the supervisor has to select one, run the report,
select another, run the report, ...

Is your intent to save this a stored query, or do it in code? If you
are doing it in code, and the Userid is text, you will have to wrap
the reference to the control in quotes:

strSQL = "SELECT Stats.UserID " _
& "FROM Stats " _
& "WHERE Stats.UserID=" & chr$(34) & [Forms]![Reports
Switchboard]![UserIDCombo] & CHR$(34)

Try this. Open your form. Select a user in the combo box.
Now, go to the database window and open a new query, Select your Stats
table, add one or more columns to the query grid, then type the userid
that is currently displayed on your form into the criteria box. Run
the query. Are there any records? If no, then maybe your Stats table
doesn't have the data in it that you think it does. If there are
records, then go back to design view, type )=[Forms]![Reports
Switchboard]![UserIDCombo] into the criteria box and run the query.
Does it still return the same results as before. If not, your combo
box may not have the Bound column set the way you think it is.


--
HTH

Dale Fye


The system is set up to show all of the employees assigned
to a supervisor (that query populates the combo box). The
supervisor can then choose any number of those users to
run a query on. The query is manually triggered and
should pull only the selected employees from the list of
employees assigned to the supervisor.

As for only returning the UserID, I'm using that as a
test, it will return much more than that.

Does this help explain it?

THX!
-----Original Message-----
What are you doing that tells Access to run this query? Is the userid
field text or numeric?

Seems to me that if you already know the USERID from the combo box,
you don't have a necessity to run a select query that only returns the
UserID.

--
HTH

Dale Fye


I'm trying to construct a query that calls to a combo
box. When I select records from the combo box, the query
doesn't seem to find them. Here is the query SQL:

SELECT Stats.UserID
FROM Stats
WHERE (((Stats.UserID)=[Forms]![Reports Switchboard]!
[UserIDCombo]));

The form it calls to has a combo box named UserIDCombo
without any control source set (tried setting it, didn't
work), Row source as:
SELECT AgentsByTeam.UserID, AgentsByTeam.NAME FROM
AgentsByTeam;

2 columns (1st bound - UserID), Multi Select set to
extended.

What am I missing? Any help would be greatly appreciated!


.
 
Back
Top