Parameter Query Help

J

Jay

Hi,

I'm trying to do womething which I know is very simple, so please forgive my
ignorance:)

I have a simple table detailing jobs assigned to staff members. I want to
have a query which pulls a specified member of staff's records, with the
staff member being picked from a pull down list (combo box?). So the user
selects the staff name from a small pull down list and the query then
returns records relating to that member of staff.

I'd really appreciate it if anyone could just point me in the right
direction (design view if possible & just high-level as I used to do this
years ago and it'll come back to me with a little nudge I'm sure).

Thanks a lot.

Cheers
Jason
 
R

Rick Brandt

Jay said:
Hi,

I'm trying to do womething which I know is very simple, so please
forgive my ignorance:)

I have a simple table detailing jobs assigned to staff members. I
want to have a query which pulls a specified member of staff's
records, with the staff member being picked from a pull down list
(combo box?). So the user selects the staff name from a small pull
down list and the query then returns records relating to that member
of staff.

I'd really appreciate it if anyone could just point me in the right
direction (design view if possible & just high-level as I used to do
this years ago and it'll come back to me with a little nudge I'm
sure).

Create a small Form with the ComboBox on it and a button. Give the ComboBox a
RowSource that will provide the names of the staff members and then in the
OnClick event of the button open the query. That will look like...

DoCmd.OpenQuery "NameOfQuery"

In the query's design give it a criteria entry for the StaffMember field that
references the ComboBox on the form. This would look similar to...

[Forms]![FormName]![ComboBoxName]
 
J

Jay

Jay said:
Hi,

I'm trying to do womething which I know is very simple, so please
forgive my ignorance:)

I have a simple table detailing jobs assigned to staff members. I
want to have a query which pulls a specified member of staff's
records, with the staff member being picked from a pull down list
(combo box?). So the user selects the staff name from a small pull
down list and the query then returns records relating to that member
of staff.

I'd really appreciate it if anyone could just point me in the right
direction (design view if possible & just high-level as I used to do
this years ago and it'll come back to me with a little nudge I'm
sure).

Create a small Form with the ComboBox on it and a button. Give the ComboBox a
RowSource that will provide the names of the staff members and then in the
OnClick event of the button open the query. That will look like...

DoCmd.OpenQuery "NameOfQuery"

In the query's design give it a criteria entry for the StaffMember field that
references the ComboBox on the form. This would look similar to...

[Forms]![FormName]![ComboBoxName]

Cheers Rick, that's a great help. What's the difference between assigning
the macro to the OnClick event & the AfterUpdate event?

-J-
 
S

Steve Schapel

Jay,

If you want the macro to be run when you select/enter an item in a
combobox, the After Update event is applicable here. If you want the
macro to be run via a command button, the Click event is applicable.
 
J

Jay

Jay,

If you want the macro to be run when you select/enter an item in a
combobox, the After Update event is applicable here. If you want the
macro to be run via a command button, the Click event is applicable.

That's what I thought - I was just a bit confused with Rick advising to use
the OnClick property for a combo box. Thanks for clarifying it.

Cheers
-Jay-
 
J

Jay

That's what I thought - I was just a bit confused with Rick advising to use
the OnClick property for a combo box. Thanks for clarifying it.

Cheers
-Jay-
My mistake. Rick suggested having a combo box for the pulldown & a button to
run the query. So he wasn't suggesting using OnClick for the combo - my
apolgies, Rick.

Is having a button for a combo box common practice? To ensure that the user
doesn't choose the wrong person 1st time & can be sure of their choice,
before clicking on the command button? Just good practice, I suppose.

Jay
 
D

Douglas J. Steele

Jay said:
My mistake. Rick suggested having a combo box for the pulldown & a button
to
run the query. So he wasn't suggesting using OnClick for the combo - my
apolgies, Rick.

Is having a button for a combo box common practice? To ensure that the
user
doesn't choose the wrong person 1st time & can be sure of their choice,
before clicking on the command button? Just good practice, I suppose.

Often you'll have more than one control linked to the query. If you put the
logic in the AfterUpdate of the combo box, you might not have supplied all
of the values yet. Even if you've only got one parameter now, you might need
more in the future, so it's probably simplest to start with having a button
to signify you're done.
 
S

Steve Schapel

Just a style difference, I think, but I would always use the combobox's
After Update event *unless*, as Doug says, the query needs to refer to
more than one control on the form.
 
D

Douglas J. Steele

Heck, I kick a lot of things off from the AfterUpdate event of text boxes,
much less combo boxes! <g>
 
S

Steve Schapel

Me too, Doug. And checkboxes. Oh, and option groups - I like option
groups. And I like AfterUpdate :)
 

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

Similar Threads


Top