Newbie question, how to use variables in query

Ben2k

Board Regular
Joined
Oct 16, 2002
Messages
77
Hi,

Quite new to access 2000, first project

I have a form where I have put two labels and two text boxes

label1, label2, text1, text2

I want users to enter a start date in text 1 and an end date in text 2

I also have a command button, when this is pressed I want to use the values of text 1 and 2 as parameters in a query

i.e. Between text1 and text2

How do I do it?

Thanks

Ben
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Go to the query, in Design view.

In the Criteria row below the date field that you want to filter, type

Between "#" & Forms![YourSearchForm]![TheFirstDateField] & "#" and "#" & Forms![YourSearchForm]![TheSecondDateField] & "#"

The "#" bits are to tell Access that you are working with dates. Adjust names to suit.

If the command button on the form already opens the form, great. Otherwise delete it, turn the Control Wizard on (the wand thingy on the Toolbox), drag another command button onto the form, and follow the prompts.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,771
Messages
6,161,847
Members
451,723
Latest member
Rachetsely

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