Can't find the field '|' referred to in your expression

Doozer1979

Registered User.
Local time
Today, 20:52
Joined
Jul 4, 2007
Messages
32
i've got the follwing function in my VBA code that is throwing out the error

Can't find the field '|' referred to in your expression.

Is their something wrong with my syntax?



Code:
Dim LTotalF As Long
        
        LTotalF = DCount("Cri_Ref_No", "Temporary_Recorded_Crime_Committed_Formatted", [Cri_Committed_Date] >= Me.txtCSEPStart And [Cri_Committed_Date] <= Me.txtCSEPEnd)
 
That should be:
Code:
LTotalF = DCount("Cri_Ref_No", _
    "Temporary_Recorded_Crime_Committed_Formatted", _
    "[Cri_Committed_Date] >=#" & Me.txtCSEPStart _
    & "# And [Cri_Committed_Date] <=#" & Me.txtCSEPEnd & "#")
 
Your where has to be a string, assuming they are both dates in AMERICAN format:
LTotalF = DCount("Cri_Ref_No", "Temporary_Recorded_Crime_Committed_Formatted", "[Cri_Committed_Date] >= #" & Me.txtCSEPStart & "# And [Cri_Committed_Date] <= #" & Me.txtCSEPEnd & #")
 

Users who are viewing this thread

Back
Top Bottom