D
DIH
Hi all,
First some background info:
See:
http://groups.google.com/group/micr...ddcf69d?hl=en&q=fiscal+month#f69070bfd762f19f
I have a lookup table called [tblFiscalLookup1].
I have a unbound control on a form called
[forms]![frmDailyProdReport]![txtStartDate].
When the user clicks a date in a calendar control (which in turn puts
the selected date into a control called CalStartDate) the following code
will return the first day of our (rather unique) fiscal month by looking
up the value from the lookup table (and then puts that date into a
control called txtStartDate (which gets used in a query later on):
==================================================================
Private Sub CalStartDate_AfterUpdate()
If IsNull(Me.CalStartDate) Then
Exit Sub
End If
intMonthNum = DLookup("MonthOfYear", _
"tblFiscalLookUp1", _
"DayOfYear=" & Format(CalStartDate, "\#yyyy-m-d\#"))
Me.txtstartdate = DMin("DayOfYear", _
"tblFiscalLookUp1", _
"MonthOfYear=" & intMonthNum)
End Sub
====================================================================
I then can use the WHERE clause in a summary query to give the month to
date results using:
Between [Forms]![frmDailyProdReport].[txtStartDate] And
[Forms]![frmDailyProdReport].[cbostartdate].
What I now need is a query that will return the "previous" month's month
to date value. I started out thinking that since I already have the
first day of the current fiscal month , all I would need to do is
subtract that date by one and use a lookup again to give me what the new
first date of the previous month is.
Here is what I've come up with but I get the following error:
"You did not enter the keyword AND in the Between... And operator."
Between DMin("DayOfYear","tblFiscalLookUp1","MonthOfYear=" &
Dlookup("MonthOfYear","tblFiscalLookUp1","DayOfYear=" &
[txtStartDate]-1) And ([forms]![frmDailyProdReport]![txtStartDate]-1))
I know something just isn't right with this though.
In other words if the first day of a fiscal month starts on 11/23/08, I
would then get as one value 11/22/08 and I would then need the first
date of the fiscal month that has 11/22/08 in it.
I know this may seem rather confusing, so any help would be greatly
appreciated. Thanks again to Marshall Barton who gave me the answer to
my original post.
Dave
First some background info:
See:
http://groups.google.com/group/micr...ddcf69d?hl=en&q=fiscal+month#f69070bfd762f19f
I have a lookup table called [tblFiscalLookup1].
I have a unbound control on a form called
[forms]![frmDailyProdReport]![txtStartDate].
When the user clicks a date in a calendar control (which in turn puts
the selected date into a control called CalStartDate) the following code
will return the first day of our (rather unique) fiscal month by looking
up the value from the lookup table (and then puts that date into a
control called txtStartDate (which gets used in a query later on):
==================================================================
Private Sub CalStartDate_AfterUpdate()
If IsNull(Me.CalStartDate) Then
Exit Sub
End If
intMonthNum = DLookup("MonthOfYear", _
"tblFiscalLookUp1", _
"DayOfYear=" & Format(CalStartDate, "\#yyyy-m-d\#"))
Me.txtstartdate = DMin("DayOfYear", _
"tblFiscalLookUp1", _
"MonthOfYear=" & intMonthNum)
End Sub
====================================================================
I then can use the WHERE clause in a summary query to give the month to
date results using:
Between [Forms]![frmDailyProdReport].[txtStartDate] And
[Forms]![frmDailyProdReport].[cbostartdate].
What I now need is a query that will return the "previous" month's month
to date value. I started out thinking that since I already have the
first day of the current fiscal month , all I would need to do is
subtract that date by one and use a lookup again to give me what the new
first date of the previous month is.
Here is what I've come up with but I get the following error:
"You did not enter the keyword AND in the Between... And operator."
Between DMin("DayOfYear","tblFiscalLookUp1","MonthOfYear=" &
Dlookup("MonthOfYear","tblFiscalLookUp1","DayOfYear=" &
[txtStartDate]-1) And ([forms]![frmDailyProdReport]![txtStartDate]-1))
I know something just isn't right with this though.
In other words if the first day of a fiscal month starts on 11/23/08, I
would then get as one value 11/22/08 and I would then need the first
date of the fiscal month that has 11/22/08 in it.
I know this may seem rather confusing, so any help would be greatly
appreciated. Thanks again to Marshall Barton who gave me the answer to
my original post.
Dave