Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaring a Variable in a Select Query????? 1

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
I have a select query in Access2000. As part of the where clause I have this line:

(Att.DateWeekStarting Between Nz([Enter Start Date],Date()-7) And Nz([Enter End Date],DateAdd("ww",-14,Date())))

Is there a way to have the start date and end date as two variables?
Ideally I would like to have only one popup window and have the end date automatically be set to 13 weeks less than the entered date, which would be the starting date. Thanks for any help that may be provided.
 

Looking at your criteria again, it appears you have the default values revresed for a date range search. If the user enters no dates, the criteria would be Between Today-7 days And Today-14 weeks or 9/13/01 And 6/14/01.

You can do the following to have only one parameter window pop up.

(Att.DateWeekStarting
Between Nz([Enter Start Date],DateAdd("ww",-14,Date()))
And Dateadd("ww",13,Nz([Enter Start Date],DateAdd("ww",-14,Date())))) Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Typed it and double checked for type-o's and got a syntax error (missing operator) as a result.
 

Well - I just copied and pasted it into Access and it ran with no errors. Guess you need to recheck your typing. Or maybe you could copy and paste? Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
The copy and paste trick worked. Thanks alot, I kind thought you would come up with the answer. By the way is there a way to make that 13 week period into a numeric variable? That way I could add to it or subtract from it if need and have the 13 weeks as the default value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top