Pass selection from combo box as argument for query

F

Frustrated

A table contains material description and also the
material "group" to which each description belongs.
For instance glass tempered & glass double pane are both
in the group "glass" and metal silver & metal black are
both in the group "metal".
Have a form for a PO that contains both the material
description and the material group to which the material
description belongs. Since the material description
uniquely identifies the material group, I want to auto
populate material group. I defined a query that gets the
right group given the description but have been unable to
automate passing the argument(ie: the description
selected from a combo box) to the query. Instead,
whenever I run the form and it gets to the event that
invokes the query, it pops up a window seeking the
description. If I enter the description and click OK, all
works but that should not be needed - there is a way to
pass the description selected from the combo box to the
query but I have been unable to figure it out.
Can anyone help?
Thanks,
Frustrated
 
M

Marshall Barton

Frustrated said:
A table contains material description and also the
material "group" to which each description belongs.
For instance glass tempered & glass double pane are both
in the group "glass" and metal silver & metal black are
both in the group "metal".
Have a form for a PO that contains both the material
description and the material group to which the material
description belongs. Since the material description
uniquely identifies the material group, I want to auto
populate material group. I defined a query that gets the
right group given the description but have been unable to
automate passing the argument(ie: the description
selected from a combo box) to the query. Instead,
whenever I run the form and it gets to the event that
invokes the query, it pops up a window seeking the
description. If I enter the description and click OK, all
works but that should not be needed - there is a way to
pass the description selected from the combo box to the
query but I have been unable to figure it out.


A query pop up prompt means that the name in the query is
different from the name you're actually using in the
table/form.

A common way to coordinate combo boxes is to set the second
combo's RowSource to a query such as:

SELECT ID, Description
FROM Materials
WHERE Group = Forms!theform.firstcombo

Then, use a little code in the first combo's AfterUpdate
event procedure:

Me.secondcombo = Null 'clear any existing value
Me.secondcombo.Requery
 

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