Combo Box executing query, issues

C

cmraguilar

I am trying to set up a combo box that will execute a query. I've searched
the site and haven't found anything that seems to help. Here is my situation.

I have a combo box, cboZoneSelect, that has a source from a table, tblZone.
The combo box populates fine with no problems.

I have a query that pulls
Table:
tblZone
tblDetail

Fields:
tblZone.Zone
tblDetail.ZoneId(fk)
tblDetail.Country
tblDetail.Product
tblDetail.StandardLevel
tblDetail.PackageType.

Under tblZone.Zone I have the criteria set to
[Forms]![Switchboard]![cboZoneSelect].[AfterUpdate]

When I run the query it requests the parameter from
Forms!Switchboard!cboZoneSelect.AfterUpdate
After entering a parameter, it runs perfectly.

My question is what else do I need to do to have the query executed after
selecting a parameter from the combo box.
 
J

John Spencer

TRY

[Forms]![Switchboard]![cboZoneSelect]

As the criteria. You don't say how you are causing the query to run, so no
advice there.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
G

George Nicholson

Remove AfterUpdate from the Criteria:
Forms!Switchboard!cboZoneSelect

You want the value of the combobox. AfterUpdate is an event, and does not
return a value (and even if this event did return a value, it wouldn't be
the value that you want).
My question is what else do I need to do to have the query executed after
selecting a parameter from the combo box.

Call/Execute the revised query within AfterUpdate, causing it to run when
that event fires.

--
HTH,
George


cmraguilar said:
I am trying to set up a combo box that will execute a query. I've searched
the site and haven't found anything that seems to help. Here is my
situation.

I have a combo box, cboZoneSelect, that has a source from a table,
tblZone.
The combo box populates fine with no problems.

I have a query that pulls
Table:
tblZone
tblDetail

Fields:
tblZone.Zone
tblDetail.ZoneId(fk)
tblDetail.Country
tblDetail.Product
tblDetail.StandardLevel
tblDetail.PackageType.

Under tblZone.Zone I have the criteria set to
[Forms]![Switchboard]![cboZoneSelect].[AfterUpdate]

When I run the query it requests the parameter from
Forms!Switchboard!cboZoneSelect.AfterUpdate
After entering a parameter, it runs perfectly.

My question is what else do I need to do to have the query executed after
selecting a parameter from the combo box.
 
C

cmraguilar

Thats where i'm stuck. I need help executing the query within the AfterUpdate.

George Nicholson said:
Remove AfterUpdate from the Criteria:
Forms!Switchboard!cboZoneSelect

You want the value of the combobox. AfterUpdate is an event, and does not
return a value (and even if this event did return a value, it wouldn't be
the value that you want).
My question is what else do I need to do to have the query executed after
selecting a parameter from the combo box.

Call/Execute the revised query within AfterUpdate, causing it to run when
that event fires.

--
HTH,
George


cmraguilar said:
I am trying to set up a combo box that will execute a query. I've searched
the site and haven't found anything that seems to help. Here is my
situation.

I have a combo box, cboZoneSelect, that has a source from a table,
tblZone.
The combo box populates fine with no problems.

I have a query that pulls
Table:
tblZone
tblDetail

Fields:
tblZone.Zone
tblDetail.ZoneId(fk)
tblDetail.Country
tblDetail.Product
tblDetail.StandardLevel
tblDetail.PackageType.

Under tblZone.Zone I have the criteria set to
[Forms]![Switchboard]![cboZoneSelect].[AfterUpdate]

When I run the query it requests the parameter from
Forms!Switchboard!cboZoneSelect.AfterUpdate
After entering a parameter, it runs perfectly.

My question is what else do I need to do to have the query executed after
selecting a parameter from the combo box.
 
G

George Nicholson

Thats where i'm stuck. I need help executing the query within the
AfterUpdate.

It depends on what the query is and what you expect to happen.

If this is a simple Select query and you just want to display the results to
the user on screen:
DoCmd.OpenQuery "qryQueryName",acNormal

If you want to run some sort of Action query (Append, Update, Delete) under
the hood:
CurrentDB.Execute "qryQueryName", dbFailOnError

either line, or variations thereof, can be placed directly in the
AfterUpdate event.

--
HTH,
George


cmraguilar said:
Thats where i'm stuck. I need help executing the query within the
AfterUpdate.

George Nicholson said:
Remove AfterUpdate from the Criteria:
Forms!Switchboard!cboZoneSelect

You want the value of the combobox. AfterUpdate is an event, and does not
return a value (and even if this event did return a value, it wouldn't be
the value that you want).
My question is what else do I need to do to have the query executed
after
selecting a parameter from the combo box.

Call/Execute the revised query within AfterUpdate, causing it to run when
that event fires.

--
HTH,
George


cmraguilar said:
I am trying to set up a combo box that will execute a query. I've
searched
the site and haven't found anything that seems to help. Here is my
situation.

I have a combo box, cboZoneSelect, that has a source from a table,
tblZone.
The combo box populates fine with no problems.

I have a query that pulls
Table:
tblZone
tblDetail

Fields:
tblZone.Zone
tblDetail.ZoneId(fk)
tblDetail.Country
tblDetail.Product
tblDetail.StandardLevel
tblDetail.PackageType.

Under tblZone.Zone I have the criteria set to
[Forms]![Switchboard]![cboZoneSelect].[AfterUpdate]

When I run the query it requests the parameter from
Forms!Switchboard!cboZoneSelect.AfterUpdate
After entering a parameter, it runs perfectly.

My question is what else do I need to do to have the query executed
after
selecting a parameter from the combo box.
 

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