Hi,
I can't seem to understand what's amiss here and would be grateful if someone could cast an eye over this and perhaps see what I can't.
I'm getting two different results when using a select query with totals and DCount in vba when I thought I should get the same result.
The query returns 19 which is what I expected and going through the source data is correct
VBA which returns 21 and is wrong
What am I missing in the VBA that's giving me the wrong count, I just can't figure it out.
SmallTime
I can't seem to understand what's amiss here and would be grateful if someone could cast an eye over this and perhaps see what I can't.
I'm getting two different results when using a select query with totals and DCount in vba when I thought I should get the same result.
The query returns 19 which is what I expected and going through the source data is correct
Code:
SELECT Count([All Referrals].Received) AS CountOfReceived
FROM [All Referrals]
WHERE ((([All Referrals].Received) Between [Forms]![FrmWhatHappened]![TxtStartDate] And [Forms]![FrmWhatHappened]![TxtEndDate]));
VBA which returns 21 and is wrong
Code:
Dim NewCaseCount As Integer
NewCaseCount = DCount("[ReferralID]", "[All Referrals]", "[Received] between #" & Forms![FrmWhatHappened]![TxtStartDate] & "# AND #" & Forms![FrmWhatHappened]![TxtEndDate] & "#")
What am I missing in the VBA that's giving me the wrong count, I just can't figure it out.
SmallTime