G
gm6243 via AccessMonster.com
Dear All
I have a form with a listbox lboemployee which has a record source
tblEmployee. I have a report Employee Sales for the Month.
I want to print individual reports for each of the employee as a separate
report when cmdprintreports is clicked.
I want to avoid printing one report at a time.
I have been some what successful with the following code:
The code works until there is a employee who has no data in the report
I get the pop up for NO DATA and it stops printing reports for the other
employees.
Can someone please help in completing the code so that if there is no data
for one employee, it will still print the report for all subsequent employees
in the list.
Thank You
The Code is a below:
Private Sub Command62_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim intItem As Integer
Dim lbo As ListBox
Dim strWhere As String
Dim blRet As Boolean
Set lbo = Me.Lbopkagt
On Error GoTo Err_Handler
strWhere = "1=1"
If IsNull(Me.manager) Then
MsgBox "Please Select A Manager and Retry", vbExclamation, "Invalid
Selection"
Cancel = True
Else
If Not IsNull(Me.manager) Then
strWhere = strWhere & " AND " & "[manager] = '" & Me.manager & "'"
End If
If Not IsNull(Me.Accession) Then
strWhere = strWhere & " AND " & "[sgmnt] = '" & Me.Accession & "'"
End If
If IsDate(Me.txtEndDate) Then
strWhere = strWhere & " AND " & "[reportdate] = " & GetDateFilter((Me.
txtEndDate) + 1)
ElseIf Nz(Me.txtEndDate) <> "" Then
strError = cInvalidDateError
End If
End If
For intItem = 0 To lbo.ListCount - 1
Debug.Print lbo.ItemData(intItem)
strWhere = strWhere & " AND " & "Repname=""" & lbo.ItemData(intItem)
& """"
DoCmd.OpenReport "Daily Count By Sales Rep" _
, , , strWhere
Next
Exit_Handler:
Exit Sub
Err_Handler:
Select Case Err.Number
Case 2501
Case Else
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
End Select
Resume Exit_Handler
End Sub
Thank You
I have a form with a listbox lboemployee which has a record source
tblEmployee. I have a report Employee Sales for the Month.
I want to print individual reports for each of the employee as a separate
report when cmdprintreports is clicked.
I want to avoid printing one report at a time.
I have been some what successful with the following code:
The code works until there is a employee who has no data in the report
I get the pop up for NO DATA and it stops printing reports for the other
employees.
Can someone please help in completing the code so that if there is no data
for one employee, it will still print the report for all subsequent employees
in the list.
Thank You
The Code is a below:
Private Sub Command62_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim intItem As Integer
Dim lbo As ListBox
Dim strWhere As String
Dim blRet As Boolean
Set lbo = Me.Lbopkagt
On Error GoTo Err_Handler
strWhere = "1=1"
If IsNull(Me.manager) Then
MsgBox "Please Select A Manager and Retry", vbExclamation, "Invalid
Selection"
Cancel = True
Else
If Not IsNull(Me.manager) Then
strWhere = strWhere & " AND " & "[manager] = '" & Me.manager & "'"
End If
If Not IsNull(Me.Accession) Then
strWhere = strWhere & " AND " & "[sgmnt] = '" & Me.Accession & "'"
End If
If IsDate(Me.txtEndDate) Then
strWhere = strWhere & " AND " & "[reportdate] = " & GetDateFilter((Me.
txtEndDate) + 1)
ElseIf Nz(Me.txtEndDate) <> "" Then
strError = cInvalidDateError
End If
End If
For intItem = 0 To lbo.ListCount - 1
Debug.Print lbo.ItemData(intItem)
strWhere = strWhere & " AND " & "Repname=""" & lbo.ItemData(intItem)
& """"
DoCmd.OpenReport "Daily Count By Sales Rep" _
, , , strWhere
Next
Exit_Handler:
Exit Sub
Err_Handler:
Select Case Err.Number
Case 2501
Case Else
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
End Select
Resume Exit_Handler
End Sub
Thank You