D
Dan @BCBS
This may be a duplicate - I have a strange error when posting...
My Goal: A form has 1 command button, 2 list boxes and 1 combo box (and 2
text boxes for the start & stop dates). When the user clicks the command
button the results are (DoCmd.SendObject acReport) but before that = 9
options based on the 2 list boxes and 1 combo box...
Here is what I have but I would have no problem starting over if it looks
like a mess to you... It only partially works::
Private Sub cmdEMailAudit_Click()
On Error GoTo Err_cmdAudit2_Click
Dim stDocName As String
Dim X As Integer
Dim stArea As Variant
stDocName = "rptQualityAuditList"
strReport = "Audit"
If IsNull(Me.txtStart) Or IsNull(Me.txtEnd) Then
MsgBox "Please enter a start and end date to run this report."
Exit Sub
Else
X = 0
For Each stArea In lstArea.ItemsSelected
If X = 0 Then
stAreaList = "In('" & lstArea.ItemData(stArea) & "'"
Else
stAreaList = stAreaList & ",'" & lstArea.ItemData(stArea) &
"'"
End If
X = X + 1
Next stArea
stAreaList = stAreaList & ")"
End If
stStart = Me.txtStart
stEnd = Me.txtEnd
If stAreaList = ")" Then
MsgBox "Please select a Location."
Else
DoCmd.SendObject acReport, stDocName, acFormatRTF, , , , , , True
End If
Exit_cmdAudit2_Click:
Exit Sub
Err_cmdAudit2_Click:
MsgBox err.Number & " " & err.Description
Resume Exit_cmdAudit2_Click
End Sub
My Goal: A form has 1 command button, 2 list boxes and 1 combo box (and 2
text boxes for the start & stop dates). When the user clicks the command
button the results are (DoCmd.SendObject acReport) but before that = 9
options based on the 2 list boxes and 1 combo box...
Here is what I have but I would have no problem starting over if it looks
like a mess to you... It only partially works::
Private Sub cmdEMailAudit_Click()
On Error GoTo Err_cmdAudit2_Click
Dim stDocName As String
Dim X As Integer
Dim stArea As Variant
stDocName = "rptQualityAuditList"
strReport = "Audit"
If IsNull(Me.txtStart) Or IsNull(Me.txtEnd) Then
MsgBox "Please enter a start and end date to run this report."
Exit Sub
Else
X = 0
For Each stArea In lstArea.ItemsSelected
If X = 0 Then
stAreaList = "In('" & lstArea.ItemData(stArea) & "'"
Else
stAreaList = stAreaList & ",'" & lstArea.ItemData(stArea) &
"'"
End If
X = X + 1
Next stArea
stAreaList = stAreaList & ")"
End If
stStart = Me.txtStart
stEnd = Me.txtEnd
If stAreaList = ")" Then
MsgBox "Please select a Location."
Else
DoCmd.SendObject acReport, stDocName, acFormatRTF, , , , , , True
End If
Exit_cmdAudit2_Click:
Exit Sub
Err_cmdAudit2_Click:
MsgBox err.Number & " " & err.Description
Resume Exit_cmdAudit2_Click
End Sub