D
DS
I have this statement that keeps giving me a compile error on
CDDiscountManID so I'm assuming once again the syntax is wrong...it's in the
first two if parts.
Thanks
DS
'DISCOUNTS
If DateValue(Forms!frmReportDates!TxtStart) < DateAdd("yyyy", -1, Date)
And _
DateValue(Forms!frmReportDates!TxtEnd) < DateAdd("yyyy", -1, Date)
Then
'OLD
Set RS = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"[MS
Access;Database=\\Backoffice\C$\Warehouse\History.mdb].tblDiscountDetails "
& _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#" And
CDDiscountManID = Me.EmployeeID), dbOpenSnapshot)
Me.TxtDiscounts = Nz(RS(0), 0)
RS.Close
ElseIf DateValue(Forms!frmReportDates!TxtStart) < DateAdd("yyyy", -1,
Date) And _
DateValue(Forms!frmReportDates!TxtEnd) >= DateAdd("yyyy", -1, Date)
Then
'OLD AND NEW
Set RS = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"[MS
Access;Database=\\Backoffice\C$\Warehouse\History.mdb].tblDiscountDetails "
& _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#" And
CDDiscountManID = Me.EmployeeID), dbOpenSnapshot)
Set RS2 = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"tblDiscountDetails " & _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#" And
CDDiscountManID = Me.EmployeeID), dbOpenSnapshot)
Me.TxtDiscounts = Nz(RS(0), 0) + Nz(RS2(0), 0)
RS.Close
RS2.Close
ElseIf DateValue(Forms!frmReportDates!TxtStart) >= DateAdd("yyyy", -1,
Date) And _
DateValue(Forms!frmReportDates!TxtEnd) >= DateAdd("yyyy", -1, Date)
Then
'New
Me.TxtDiscounts = Nz(DCount("CDCheckID", "tblDiscountDetails",
"CDBizDay BETWEEN #" & Forms!frmReportDates!TxtStart & "# AND #" &
Forms!frmReportDates!TxtEnd & "# And CDDiscountManID = " & Me.EmployeeID),
0)
End If
CDDiscountManID so I'm assuming once again the syntax is wrong...it's in the
first two if parts.
Thanks
DS
'DISCOUNTS
If DateValue(Forms!frmReportDates!TxtStart) < DateAdd("yyyy", -1, Date)
And _
DateValue(Forms!frmReportDates!TxtEnd) < DateAdd("yyyy", -1, Date)
Then
'OLD
Set RS = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"[MS
Access;Database=\\Backoffice\C$\Warehouse\History.mdb].tblDiscountDetails "
& _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#" And
CDDiscountManID = Me.EmployeeID), dbOpenSnapshot)
Me.TxtDiscounts = Nz(RS(0), 0)
RS.Close
ElseIf DateValue(Forms!frmReportDates!TxtStart) < DateAdd("yyyy", -1,
Date) And _
DateValue(Forms!frmReportDates!TxtEnd) >= DateAdd("yyyy", -1, Date)
Then
'OLD AND NEW
Set RS = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"[MS
Access;Database=\\Backoffice\C$\Warehouse\History.mdb].tblDiscountDetails "
& _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#" And
CDDiscountManID = Me.EmployeeID), dbOpenSnapshot)
Set RS2 = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"tblDiscountDetails " & _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#" And
CDDiscountManID = Me.EmployeeID), dbOpenSnapshot)
Me.TxtDiscounts = Nz(RS(0), 0) + Nz(RS2(0), 0)
RS.Close
RS2.Close
ElseIf DateValue(Forms!frmReportDates!TxtStart) >= DateAdd("yyyy", -1,
Date) And _
DateValue(Forms!frmReportDates!TxtEnd) >= DateAdd("yyyy", -1, Date)
Then
'New
Me.TxtDiscounts = Nz(DCount("CDCheckID", "tblDiscountDetails",
"CDBizDay BETWEEN #" & Forms!frmReportDates!TxtStart & "# AND #" &
Forms!frmReportDates!TxtEnd & "# And CDDiscountManID = " & Me.EmployeeID),
0)
End If