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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with WHERE CONDITION 1

Status
Not open for further replies.

dcurtis

Technical User
May 1, 2003
273
US
I am trying to use the following code, but want to add a where condition to the end but am having problems with format/syntax.

I want to add the condition to a field, "DATE", so it only takes items between 7/1 and 6/30 (years will advance as time does ;-) ).
Code:
DoCmd.OpenReport stDocName, acPreview
What goes here?

Thanks in advance for any and all help!

----
Access 2002 on a mixed Windows OS network.
 
Is this what you want?
DoCmd.OpenReport stDocName, acPreview, ,
"[Date] Between DateSerial(Year(Date()),7,1) AND DateSerial(Year(Date())+1,6,30)"


Duane
MS Access MVP
 
Exactly what I need, but now for a stupid question that I should know the answer to. Using between includes the dates on each end, right? So using 7/1 to 6/30 will include all entries made on 6/30.

----
Access 2002 on a mixed Windows OS network.
 
Between will include the end dates. If, however, your dates also include a time element then you would need to increase your maximum date by almost 24 hours. An alternative would be to use
DateValue([Date]) Between...

BTW: [Date] is a very poor name for a field since it is the name of a function. Every date your store has a function such as OrderDate, ShipDate, BirthDate, HireDate, etc. Specify this function when naming your field.

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top