G
Guest
Hi,
I am having a problem with DISTINCT and COUNT using Access 2003 VB. I am
using a form to pull information and a report to display it. When I run the
query below, it will count every instance of the USER_ID, not just the
DISTINCT ones. So, I get a return of 64 instead of what it should really be
which is 7.
Any thoughts on how to properly use DISCTINCT AND COUNT in this case?
Thanks.
recordSource = "SELECT DISTINCT COUNT(table.USER_ID) as count FROM table
WHERE table.CLIENTID='" & _
Forms("form").txtClientID.Value & "' AND " & _
" TIME_STAMP BETWEEN #" & Forms("form").txtFrom.Value &
"# AND #" & _
Forms("form").txtTo.Value & "#"
DoCmd.OpenReport "Report", acViewDesign
Set obsReport = Application.Reports("Report")
obsReport.recordSource = recordSource
DoCmd.Close acReport, "Report", acSaveYes
DoCmd.OpenReport "Report", acViewPreview
I am having a problem with DISTINCT and COUNT using Access 2003 VB. I am
using a form to pull information and a report to display it. When I run the
query below, it will count every instance of the USER_ID, not just the
DISTINCT ones. So, I get a return of 64 instead of what it should really be
which is 7.
Any thoughts on how to properly use DISCTINCT AND COUNT in this case?
Thanks.
recordSource = "SELECT DISTINCT COUNT(table.USER_ID) as count FROM table
WHERE table.CLIENTID='" & _
Forms("form").txtClientID.Value & "' AND " & _
" TIME_STAMP BETWEEN #" & Forms("form").txtFrom.Value &
"# AND #" & _
Forms("form").txtTo.Value & "#"
DoCmd.OpenReport "Report", acViewDesign
Set obsReport = Application.Reports("Report")
obsReport.recordSource = recordSource
DoCmd.Close acReport, "Report", acSaveYes
DoCmd.OpenReport "Report", acViewPreview