I have created 2 seperate reports using the data report designer. The source for both reports is a data environment connected to a MS Access table. The first report works fine. It is a simple report (no grouping) that lists records from the table entered by the currently logged in user and a date range the user inputs. I acheived this by changing the command text of the data environment command:
Private Sub cmdPrint_Click()
ToDate = txtTo.Text
FromDate = txtFrom.Text
sqlSelect = "SELECT * FROM tblCallDetails WHERE UserID = '" & sUserID & "' AND CallDate <= '" & ToDate & "' AND CallDate >= '" & FromDate & "'"
With deCallTrackingReports.Commands(1)
.CommandText = sqlSelect
.Execute
End With
drCallOutcomeDetails.show
End Sub
My problem is with the second report. I would like this report to list all records in a given date range regardless of the current user, however the report must be grouped by userID. I created the report with the grouping level and it works fine, however, when I duplicate the above code (without the userID WHERE criteria) so the report will only display records in a date range I keep getting an error message stating 'DataField cmdBlah.userID not found'. I suspect this has to do with the fact that I have added a grouping level of userID which creates a new command name (cmdBlahblah grouped using cmdBlahblah_grouping) and vb doesn't recognize the command object I am referring to.
I guess my question is: is there a way to change the command text of a grouped command? Is there another way to retrieve records in a data report based on user input at run-time?
Sorry for the length of this message. Any help would be appreciated. Thanks.
Private Sub cmdPrint_Click()
ToDate = txtTo.Text
FromDate = txtFrom.Text
sqlSelect = "SELECT * FROM tblCallDetails WHERE UserID = '" & sUserID & "' AND CallDate <= '" & ToDate & "' AND CallDate >= '" & FromDate & "'"
With deCallTrackingReports.Commands(1)
.CommandText = sqlSelect
.Execute
End With
drCallOutcomeDetails.show
End Sub
My problem is with the second report. I would like this report to list all records in a given date range regardless of the current user, however the report must be grouped by userID. I created the report with the grouping level and it works fine, however, when I duplicate the above code (without the userID WHERE criteria) so the report will only display records in a date range I keep getting an error message stating 'DataField cmdBlah.userID not found'. I suspect this has to do with the fact that I have added a grouping level of userID which creates a new command name (cmdBlahblah grouped using cmdBlahblah_grouping) and vb doesn't recognize the command object I am referring to.
I guess my question is: is there a way to change the command text of a grouped command? Is there another way to retrieve records in a data report based on user input at run-time?
Sorry for the length of this message. Any help would be appreciated. Thanks.