Topics Search

Run query based on value in combobox

Run query based on value in combobox
Views: 72
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:

Similar posts...

 

ComboBox not listing multiple columns

ComboBox not listing multiple columns Icon
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

referencing combobox in query Icon
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

Query based on ComboBox selection Icon
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

Query based on combobox Icon
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

Combobox Selection To Run Query Icon
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.
 

Run macro from combobox NOT based on selection

Run macro from combobox NOT based on selection Icon
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 subform combobox

Query based on subform combobox Icon
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

Query based on Value in a Combobox Icon
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.
 

Datasheet with one combobox dependent on another combobox

Datasheet with one combobox dependent on another combobox Icon
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

Three Comboboxes Icon
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.
 
Sponsored Links: