select a criteria's parameter from a combo box on a form

F

fossy

Ok, I have a table “tblEmployeesâ€, with employees training data. Out of this
table I created some queries: by training date, by employee manager, by
training type, by employee title…etc.

The query BY DATE it was pretty easy simple, as the criteria takes care of
it. When it was BY MANAGER, there are only 3 managers, so I made 3 queries
(one for each name). When I jumped to make the queries BY TYPE is when I had
problems… we have about 20+ training types, so I don’t really want to create
20 different queries.

I made a form with buttons (macros) to open the queries, and when it came to
the query BY TYPE, I placed a combo box with a list of the training types.

I want the user to select the training type from the combo box and then
click the button to place that “training type†as a parameter of the criteria
on the query. On that way, there is only one query with a open parameter as a
criteria.

Is this possible to achieve? Or do I have to make a query for each criteria?

I asked help with this and i got some answers before, but i just can't make
it work help please.
 
R

Ryan

Add this code to the command button.

PrivateSub CommandButtonName_Click()
Dim SelectedType As String
SelectedType = Me!ComboBoxName

DoCmd.OpenForm SelectedType
End Sub

In the query, you would set up criteria in the ByType column. It would look
like this.

IIf(IsNull([Forms]![YourFormName]![ByTypeComboBoxName],[ByType],[Forms]![YourFormName]![ByTypeComboBoxName]

This tells your query to show all types if the combobox is null, or if it
has a value to use that value.
 
F

fossy

Thanks alot for your rapid answer i'll give it a try and let you know how it
worked

Ryan said:
Add this code to the command button.

PrivateSub CommandButtonName_Click()
Dim SelectedType As String
SelectedType = Me!ComboBoxName

DoCmd.OpenForm SelectedType
End Sub

In the query, you would set up criteria in the ByType column. It would look
like this.

IIf(IsNull([Forms]![YourFormName]![ByTypeComboBoxName],[ByType],[Forms]![YourFormName]![ByTypeComboBoxName]

This tells your query to show all types if the combobox is null, or if it
has a value to use that value.

--
Please remember to mark this post as answered if this solves your problem.


fossy said:
Ok, I have a table “tblEmployeesâ€, with employees training data. Out of this
table I created some queries: by training date, by employee manager, by
training type, by employee title…etc.

The query BY DATE it was pretty easy simple, as the criteria takes care of
it. When it was BY MANAGER, there are only 3 managers, so I made 3 queries
(one for each name). When I jumped to make the queries BY TYPE is when I had
problems… we have about 20+ training types, so I don’t really want to create
20 different queries.

I made a form with buttons (macros) to open the queries, and when it came to
the query BY TYPE, I placed a combo box with a list of the training types.

I want the user to select the training type from the combo box and then
click the button to place that “training type†as a parameter of the criteria
on the query. On that way, there is only one query with a open parameter as a
criteria.

Is this possible to achieve? Or do I have to make a query for each criteria?

I asked help with this and i got some answers before, but i just can't make
it work help please.
 

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