running a parameter query from a simple form

Dankniseley

New Member
Joined
Mar 23, 2003
Messages
33
Hi,

I was wondering if it is possible to run a parameter query from a form where the users would simply select the paramters from 3 dropdowns.

Also, I would like the form to do the following. I have a simple query that queries a table of 4 data fields. I want the user to be able to launch the form and select 3 values from 3 different dropdowns. then click a command button and the 3 values from the 3 dropdowns are used as the 3 parameter values.

A sub form could be below the three values but is blank until the 3 dropdown values are selected and the command button is clicked. then returns the query results. This process would be repeated many time by the user. no data would need to be added to the tables.


Any help with this would be great.

Thx

Dan
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You seem to have outlined quite nicely how to do it :)

You can create your three dropdowns using the Wizards.
You can use the wizard in the query to set the criteria for the fields.

With your button you will need to requery the sub form.

This is very general so shout if you need more help with the details..

peter
 
Upvote 0
I need some steps on how to put the query into the subform.

Currently I have my three dropdowns accessing 3 gifferent tables I want to be able to store the values selected. Then, use thos selected values as my parameters for querying and re-querying.

If you could provide my on the details of how to do this in a simple form
that would be great.

here is an example

Origin port code
1
2

Destination port code
2
1

Service level
1
2
3
4
5

Priority
h
m
l


I want to be able to select one origin port code(dropdown #1)
I want to be able to select one Destination port code(dropdown #2)
I want to be able to select one Service code(dropdown #3)

use these 3 selected values as my parameter and query my full table

ori port code
dest port code
Service lvl
Priority
 
Upvote 0
The query for you subform will look like
SELECT tblData.origin, tblData.Destination, tblData.service, tblData.priority
FROM tblData
WHERE (((tblData.origin)=[Forms]![frmFilter]![cbo1]) AND ((tblData.Destination)=[Forms]![frmFilter]![Cbo2]) AND ((tblData.service)=[Forms]![frmFilter]![Cbo3]));

This is assuming that tblData is the table that you want to filter and that the three dropdowns are in a form called frmFilter and called cbo1, cbo2, cbo3.

Once you have your query you can then build a form based on it and drop it into your form with the drop boxes to make the subform.

Assuming that you call this form frmFilterSub then the refresh button will need the code
Me.frmFilterSub.Requery
to refresh the subform


HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,551
Messages
6,160,460
Members
451,648
Latest member
SuziMacca

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top