I’m trying to have the code look up the value of orders placed within a specified timeframe but cannot figure out how to format the formula. I’m sure it is a “simple” formatting issue but I’m way out of my depth here and don’t know what I’m looking for.
The error is: The expression you entered as a query parameter produced this error: ‘CustomStartV’
The original formula (abbreviated below) went from 1 Jan XX to 31 Dec XX (different XX for each year)
The custom range is giving me an xxxxxxxx error.
As always, thank you in advance
The error is: The expression you entered as a query parameter produced this error: ‘CustomStartV’
The original formula (abbreviated below) went from 1 Jan XX to 31 Dec XX (different XX for each year)
Code:
'Declares Variables
Dim Total2003c As Variant
'Assigns values to variables
TotalVal = DSum("[TotalPrice]", "[SupplyLog]")
Total2003c = DSum("[TotalPrice]", "Supplylog", "[Date Ordered] > #1/1/2003# And [Date Ordered] < #1/1/2004#")
If IsNumeric(Total2003c) = True Then
'do nothing, it is a number
Else: Total2003c = 0
End If
'Assigns values to displayed form
Me.Total2003 = Total2003c
The custom range is giving me an xxxxxxxx error.
Code:
Sub CustomRange()
Dim TotalCustom As Variant
Dim CustomStartV As Date
Dim CustomEndV As Date
'*** Checks to see that a date is entered in both fields ***
If Me.txtCustStart = "" Or Me.txtCustEnd = "" Then
End
Else
'do nothing
End If
'*** Checks to ensure start date is before end date and switches values if necessary ***
If Me.txtCustStart.Value > Me.txtCustEnd.Value Then
CustomStartV = Me.txtCustStart.Value
CustomEndV = Me.txtCustEnd.Value
Me.txtCustStart = CustomEndV
Me.txtCustEnd = CustomStartV
End If
'*** Looks up value of assets ordered between timeframe specified ***
TotalCustom = DSum("[TotalPrice]", "Supplylog", "[Date Ordered] > CustomStartV And [Date Ordered] < CustomEndV")
If IsNumeric(TotalCustom) = True Then
'do nothing, it is a number
Else: TotalCustom = 0
End If
'*** Places resulting value on screen for user to see ***
Me.TotalCust = TotalCustom
End Sub