D
Dan @BCBS
The code below belongs to a command button, it returns records based on
choices from a list box (Reviewer).
I get this nasty pop-up window saying [Reviewer] In('John Doe')
I click ok and the report shows all errors. The report is fine I use it in
other procedures.
Why am I getting this nasty pop-up???
Private Sub cmdReviewer_Click()
On Error GoTo Err_cmdReviewer_Click
Dim stDocName As String
'these need to be declared
Dim stReviewerList As String
Dim stLinkCriteria As String
'first time thru loop?
Dim FirstTime As Boolean
Dim stReviewer As Variant
stDocName = "r_ReviewerMonthly"
stReviewerList = ""
'dates
If IsNull(txtStart) Or IsNull(txtEnd) Then
MsgBox "Please enter start and end dates"
Exit Sub
End If
'get reviewer in ListReviewer
FirstTime = True
For Each stReviewer In ListReviewer.ItemsSelected
If FirstTime Then
stReviewerList = "In('" & ListReviewer.ItemData(stReviewer) & "'"
FirstTime = False
Else
stReviewerList = stReviewerList & ",'" & ListReviewer.ItemData(stReviewer) &
"'"
End If
Next stReviewer
If Not FirstTime Then
stReviewerList = stReviewerList & ")"
End If
'create criteria string
'stReviewerList
If Len(Trim(Nz(stReviewerList, ""))) > 0 Then
stLinkCriteria = stLinkCriteria & "[Reviewer] " & stReviewerList & " And """
End If
'now remove the last 'And' and spaces
stLinkCriteria = Left(stLinkCriteria, Len(stLinkCriteria) - 5)
'-------------------------
' for debugging - delete after code runs without errors
MsgBox stLinkCriteria
'-------------------------
'open report in preview mode (or) send it email
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
'DoCmd.SendObject acReport, stDocName, acFormatRTF, , , , , , True
Exit_cmdReviewer:
Exit Sub
Err_cmdReviewer_Click:
Err_cmdReviewer:
MsgBox Err.Description
Resume Exit_cmdReviewer
End Sub
choices from a list box (Reviewer).
I get this nasty pop-up window saying [Reviewer] In('John Doe')
I click ok and the report shows all errors. The report is fine I use it in
other procedures.
Why am I getting this nasty pop-up???
Private Sub cmdReviewer_Click()
On Error GoTo Err_cmdReviewer_Click
Dim stDocName As String
'these need to be declared
Dim stReviewerList As String
Dim stLinkCriteria As String
'first time thru loop?
Dim FirstTime As Boolean
Dim stReviewer As Variant
stDocName = "r_ReviewerMonthly"
stReviewerList = ""
'dates
If IsNull(txtStart) Or IsNull(txtEnd) Then
MsgBox "Please enter start and end dates"
Exit Sub
End If
'get reviewer in ListReviewer
FirstTime = True
For Each stReviewer In ListReviewer.ItemsSelected
If FirstTime Then
stReviewerList = "In('" & ListReviewer.ItemData(stReviewer) & "'"
FirstTime = False
Else
stReviewerList = stReviewerList & ",'" & ListReviewer.ItemData(stReviewer) &
"'"
End If
Next stReviewer
If Not FirstTime Then
stReviewerList = stReviewerList & ")"
End If
'create criteria string
'stReviewerList
If Len(Trim(Nz(stReviewerList, ""))) > 0 Then
stLinkCriteria = stLinkCriteria & "[Reviewer] " & stReviewerList & " And """
End If
'now remove the last 'And' and spaces
stLinkCriteria = Left(stLinkCriteria, Len(stLinkCriteria) - 5)
'-------------------------
' for debugging - delete after code runs without errors
MsgBox stLinkCriteria
'-------------------------
'open report in preview mode (or) send it email
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
'DoCmd.SendObject acReport, stDocName, acFormatRTF, , , , , , True
Exit_cmdReviewer:
Exit Sub
Err_cmdReviewer_Click:
Err_cmdReviewer:
MsgBox Err.Description
Resume Exit_cmdReviewer
End Sub