Hi All,
I was just wondering if someone could cast their eye over this and tell me where i have gone wrong.
I am using a filter form to select a user and a date for a report. I have it working with the DoCmd.OpenReport (the commented line) but are having trouble converting it to the SendObject format.
I think it is something to do with the syntax of the strRport def.
Private Sub Command9_Click()
Dim strRport As String
Const conDateFormat As String = "\#mm\/dd\/yyyy\#"
strRport = ["rptInstallerJobSheets", "[InstLastName]='" & Me.cboInstall & "' And [SchedInstallDate] = " & Format(Me.txtDate, conDateFormat) '"]
If IsNull(Me.cboInstall) = True Then
MsgBox "Please select an Installer first", vbOKOnly
Exit Sub
End If
If IsNull(Me.txtDate) = True Then
MsgBox "Please select a Date", vbOKOnly
Else
'DoCmd.OpenReport strRport, acViewPreview, , "[InstLastName]='" & Me.cboInstall & "' And [SchedInstallDate] = " & Format(Me.txtDate, conDateFormat) '"
DoCmd.SendObject acSendReport, strRport, acFormatPDF, , , , "Daily Time Sheets", , True
Exit_Command9_Click:
Exit Sub
Err_Command9_Click:
MsgBox Err.Description
Resume Exit_Command9_Click
End If
End Sub
Thanks in advance.
I was just wondering if someone could cast their eye over this and tell me where i have gone wrong.
I am using a filter form to select a user and a date for a report. I have it working with the DoCmd.OpenReport (the commented line) but are having trouble converting it to the SendObject format.
I think it is something to do with the syntax of the strRport def.
Private Sub Command9_Click()
Dim strRport As String
Const conDateFormat As String = "\#mm\/dd\/yyyy\#"
strRport = ["rptInstallerJobSheets", "[InstLastName]='" & Me.cboInstall & "' And [SchedInstallDate] = " & Format(Me.txtDate, conDateFormat) '"]
If IsNull(Me.cboInstall) = True Then
MsgBox "Please select an Installer first", vbOKOnly
Exit Sub
End If
If IsNull(Me.txtDate) = True Then
MsgBox "Please select a Date", vbOKOnly
Else
'DoCmd.OpenReport strRport, acViewPreview, , "[InstLastName]='" & Me.cboInstall & "' And [SchedInstallDate] = " & Format(Me.txtDate, conDateFormat) '"
DoCmd.SendObject acSendReport, strRport, acFormatPDF, , , , "Daily Time Sheets", , True
Exit_Command9_Click:
Exit Sub
Err_Command9_Click:
MsgBox Err.Description
Resume Exit_Command9_Click
End If
End Sub
Thanks in advance.