Excel Query to Access, w/ Variable Date

Venom

Board Regular
Joined
Jan 17, 2009
Messages
54
Hello,
I've got an Excel Query pulling data from an Access database. But I need a way to only pull items with a "Next_Due_Date" date of "<=NOW()" and a "Status" of "1".

However, "<=NOW()" is not allowed, I get a syntax error. It seems it only wants to use static values.

Any suggestions?

Thanks =D
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You can create a "Parameter Query" in MS Query.

Create the selection criteria as you would normally. It will look something like the next line.

>=#3/23/2009#

Change the selection criteria to look like the next line.

>=[Enter Date]

The square brackets [] specify that this parameter will be obtained from the user.

After you save the query and then refresh it, Excel will pop up a dialog box asking for the "date" parameter.

In the dialog box you can specify that you want it to take the parameter from a certain cell for future refreshes. You can put any formula you like in the designated cell.

Hope it helps.

Gary
 
Upvote 0
You're welcome. I'm glad my description of the process was adequate.

There is precious little regarding this topic in the MS Query help file. If you search for "Parameter" in that file you will find it.

I know that you can pass multiple parameters. I don't know if there is a limit to the number of parameters.

I have never tried hiding, locking or otherwise hacking the cell that contains the parameter. Don't know if any of that will work but its easy enough to try.

Gary
 
Upvote 0
I placed =NOW() in cell A1... Then hid Column A. So hiding the cell seems to have no issues.

It also opened the door to drop-down lists for varying auto-queries... =)
Like searches between DateA and DateB... etc.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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