Run query based on value in combobox

I have a form with a combobox containing a list of elements. The row source type for the combobox is a query (SELECT Elements.Element FROM Elements ORDER BY Elements.Element). I would like to run a different query depending on the element selected in the combobox.

Each query will be a parameter query, the parameter values being provided by text boxes on the form.

I was thinking that I could add a column to the Elements table to hold the name of the query associated with each element.

I am not sure how to retrieve both columns from the Elements table into the combobox so that the query could be executed by clicking on a button on the form

Sponsored Links:

Related Topics

Run query based on value in combobox
I have a form with a combobox containing a list of elements. The row source type for the combobox is a query (SELECT Elements.Element FROM Elements ORDER BY Elements.Element). I would like to run a different query depending on the element selected in the combobox.

Each query will be a parameter query, the parameter values being provided by text boxes on the form.

I was thinking that I could add a column to the Elements table to hold the name of the query associated with each element.

I am not sure how to retrieve both columns from the Elements table into the combobox so that the query could be executed by clicking on a button on the form.


ComboBox not listing multiple columns
I have a combo box based off a query. I want to add a second column to the combobox, so I went and added the field that I want added to the query that the combobox is based on. But when I went to go create a new ComboBox, it is not showing all the fields from the query it is based on! Why is this?


referencing combobox in query
I have been having trouble updating and referencing a combobox located in a subform. The combobox in question's row source is tied to a query that narrows the users choices based upon a previous entry in another combobox. The query does not work correctly; when you select the combobox, the control reference pop-ups as a null value each time.

Currently, I referring to the combobox control as [Forms]![Proposal]![Tests subform]![cbotestm], which works when you run the query separate from the form, but doesn't when the query is run through the combobox row source. I have seemingly tried every other syntax I can locate for the control name, e.g. [forms]![Proposal].[form]![Tests subform]![cbotestm], none of which seem to work.


Query based on ComboBox selection
I'm trying to create a query that will run based on what is selected in the combobox. I have a main form which holds the subform with the combobox. I want a button to open the query. The query field references the combobox with [forms]![subFrmName]![cboName].

My problem with this comes when I press the button and I get a message box titled "Enter Parameter Value" with my field reference line Forms!subFrmName!cboName with a text box underneath.

Am I doing something wrong? I've checked the subform name and combobox name multiple times and it appears that I'm referencing them correctly.


Query based on ComboBox selection
I'm trying to create a query that will run based on what is selected in the combobox. I have a main form which holds the subform with the combobox. I want a button to open the query. Thequery field references the combobox with [forms]![subFrmName]![cboName].

My problem with this comes when I press the button and I get a message box titled "Enter Parameter Value" with my field reference line Forms!subFrmName!cboName with a text box underneath.

I've checked the subform name and combobox name multiple times and it appears that I'm referencing them correctly.


Run macro from combobox NOT based on selection
Is it possible to call/run a macro from a combobox but it is NOT based on the combobox selection?

I know you can do it based on the combobox selection but that is not what I want. I have the user make a selection from the combobox and store it as a variable under the afterupdate event criteria. Within that same afterupdate event, I want to close the form and run a macro that will allow the user to select a file using the API command dialog box.

I have the command dialog box macro runnig fine and can call it from a button with no problem. Just need to be able to call it from within a combo box.


Query based on combobox
I have a one table that has my different fields in it. What I want to do is make a query that will search those fields depending on what is selected in the combobox.

For instance, if I want to search my data for serial numbers my query will chose the serial field if that's what the combo box is set for and then ask for an input to search against that field.

Right now I have the combobox displaying my fields, but I cannot get a query to work based on the content of the combobox


Combobox Selection To Run Query
I have a form that will show static data in textboxes that are in the form detail and form header based on the selection of a job number in a combobox that is in the form footer.

The data has to come from 2 different tables. I assume I have to create a query based on the data I want from each table. How do I link the combobox selection to the query criteria: so thatit only returns the data for that job number and once that is done how do I get it to display in the form textboxes.I know how to get the combobox to populate the textboxes with data fromone table.


Query based on subform combobox
I am trying to build a query based on a combobox that is on a subform that cascades from a combobox on a main form. So far I have :
INSERT INTO tblSubTeamEvent ( SubTeamID, EventID )
VALUES (Me!SubFormSubTeamForm.Form!cmboSubTeamSF, [Forms]![frmEvent]![EventID]);
but when I run it it asks for the parameter value of the cmboSubTeamSF. If I just ignore the question it still updates the EventID into the table but obviously not the SubTeamID. I've tried various combinations of Me! Forms! etc but can't get it to work any ideas any one


Query based on Value in a Combobox
I have a form InvInputfrm that has a combo62. When I select the value in that combobox I want it to be the parameter for my select query. This result will then populate combo64 of the InvInputfrm. Then based on the selection of combo64 a textbox will be filled in with data from column (1) of that combobox.


Three Comboboxes
I am in the process of creating a register database.

Have three comboboxes
1) Products Category
2) Products
3) Packing

1. Select the category from the first combobox,
If the category is not available update the category table by enterting the category in the combobox

2. Based on the selection of the category combobox the products will be displayed in the products combobox.
Again if the product is not available update the products table

3. Based on the products combobox the packing will be displayed in the third combobox.

I was able to get the data in the second combobox based on the selection in the first combobox. But not going to the third one. Also to add a new item if not available.


Datasheet with one combobox dependent on another combobox
I have a very simple setup:
Table Size: rows with different sizes
Table Type: rows with different types
Table Type_Size: rows showing which Sizes/Types combinations are permitted.

Thus Type 1 might be available in Size S and M, but Type 2 might only be available in Size L.

I have set up a form (I.e. for purchases) that allows a user to choose a Type from a combobox (easy query to fill the combobox). There is also a Size combobox with a simple query that addsan additional WHERE clause to only show Sizes for the specific Type selected in combobox #1 (based on the allowed combinations listed in Type_Size).

I requery combobox #2 based on two events: change in combobox #1, or change in current record. As a form this works beautifully! I can only choose Sizes appropriate to each Type. Exactly what I want.

Now I want to convert said form to a Datasheet. The query for the combobox #2 is the same across all rows of the Datasheet. In fact the results are pretty funny. If I have say 10 rows already displayed in the Datasheet and I select a row that has an item of Type 1, then all the rows with items Type 1 will list the size that was selected for that entry (since the querybecomes valid).

All the other rows will not show a size -- unless that size happens to also be available for Type 1.


Three Comboboxes Synchronized
Have three comboboxes in "ProductRegister" form
1) Products Category
2) Products
3) Packing

1. Select the category from the first combobox,
If the category is not available update the category table by enterting the category in the combobox

2. Based on the selection of the category combobox the products will be displayed in the products combobox.
Again if the product is not available update the products table

3. Based on the products combobox the packing will be displayed in the third combobox.

I was able to get the data in the second combobox based on the selection in the first combobox. But not going to the third one. Also to add a new item if not available.


Combobox to filter report
I have a report based on a query. I have a form with a combobox(Combo5) that lists all the customers that have been entered tickets into our system.

All I want is to select a customer from the combobox, click the cmd button(CustomerSearchCommand) and have the report (CustomerSearchRa) filter the report to the value in the combobox(combo5)

In trying different things I've gotten confused on what my original code was for this command button.


Refresh combobox
With the help of this forum I was able to:

in my form I have a input box that the user types in a house number. When the user clicks the street name combobox a query runs that selects the unique street names with that house number.

In the row source of the combobox I Have this:
SELECT [qry_license_combobox_populate].[Street_Name] FROM qry_license_combobox_populate ORDER BY [Street_Name];

This works fine.but if I go back and type in a new house number and click the button it does not refresh the combobox. Just trying to figure out how to re-run the query and repopulate the combobox every time the user clicks the combobox.can I fire the query to populate the combobox on the onclick event? I copied and paste the line above to the Onclick event and get errors.although I now have that line on the row source and the onclick event.


Run a query based on an input from a form
I have a form called year. the end user shall type in the year value in the same.

based on the year value, I want the query "cost_hist_db" to run for the same year. I am not able to do the same.
is it possible to run multiple queries by the click of a single button? if yes then how?
is it possible to automate the run of a query based on the results of another query? if yes how


Running a query based on a combobox within a form.
And once a value is picked, return a query that displays all the data based on that value.

I have tried using sub forms and the after update but I can't seem to figure it out.


How to make A combobox run a query?
I'm farily new to access, and would like assistance, in this (I guess) easy question.

I would like to have a combo box, on a form, with values in it.
When I choose value 1 I would like to run Query 1
When I choose value 2 I would like to run Query 2
and so on.

Please explain how to do this, considering I'm new to this


Dynamically set the row source of a combobox???
I have a combobox filter on a mainform. I have a combobox filter on a subform - the values of which are derived from a hard coded query.

Is it possible to change the row source of the subform combo based on what is clicked on in the mainform combobox filter? I also want to be able to clear the combo's rowsource completely - when add new record is clicked.


valiadation rule violation (again)
I have a update query running from the afterupdate on a cascading combobox which is really throwing me. The query is very basic:
INSERT INTO tblEvent ( VenueRoomID )
VALUES (Forms!frmEvent!cmboVenueRoom);
but it gives me the above error. I have checked all the usual violations like required field indexing etc. but none are set. The other issue is that if I allow the update anyway (by saying yes to the question if I want to run the query anyway) it does update the table. However when I go back to the form with the same record it deletes it from the table. I presume this is something to do with the combobox requerying each time. I also have a field on the form which should show the record that has been already saved in the table with the control source of VenueRoomID this fills in when I select the room in the combobox but disappears when I return to the form for the instance of the Event because the table entry is cancelled by the combobox. Can anyone tell me what I am doing wrong please