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

Between...And Function in Queries - Not Returning All Records

Status
Not open for further replies.

Tranquilo

Technical User
Oct 30, 2001
13
0
0
US
I have a table that stores our gross sales per month. There are two fields - The first is the date that the gross sales were recorded stored as a date/time field formatted "mm/yyyy". The other field is the gross sales field (currency). The problem that I am having is with the Between...And function. I have a query that pulls gross sales values from the table to show the total sales in a given period (for tax purposes). Last year, this query worked fine with the following criteria:

Between [Forms]![frmCalculateTax]![BeginDate] And DateAdd("m",[Forms]![frmCalculateTax]![EndDate],1)

The [BeginDate] and [EndDate] fields are both unbound fields on a form ([frmCalculateTax]) that are also formatted as date/time "mm/yyyy".

It still works when I request a full calendar year (in this instance 1/2001 - 12/2001), but when I ask for a quarter (10/2001 - 12/2001) the query does not pick up the first month. No matter how I modify the [BeginDate] in the between statement, I can't seem to pick up the first month. I thought that this type of statement was supposed to be inclusive of the values it was given, but this doesn't seem to be the case.

It's probably something simple, but I can't figure it out. What's going on?
 
Just from looking at it, I see that the dateadd function is written incorrectly.... to add 1 month to the end date, it should be:
Code:
DateAdd("m",1,[Forms]![frmCalculateTax]![EndDate])
Try that, and see what happens...

GComyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top