|
cimoli (TechnicalUser) |
10 Jun 12 23:08 |
I made progress. I now have a working Email button on my Access 2010 form. Could someone review my work? I am not a VBA person per se. I noted in GREEN down below the command that i am not familiar with. DoCmd.SendObject acReport, stDocName, acFormatPDF
Also, I am not sure if I should have that sendobject in more than 1 place. You see, in my button, there are 2 possible report choices. The ReportNum field decides which one to use for a given Hotel.
The SendObject examples on the internet were exotic with many parameters. So I worry that I did not get this exactly right. Can you check my work? You can criticize all you want because this coding is not my ballywick. Thanks. Cimoli.
Private Sub cmdEmailReport_Click() 'We have 2 kinds of reports based on group or non group walkin reservations. '1- a regular Group reservation report #10 that uses report rptTicketIND and '2- a Splinter NON Group reservation #20 that uses report rptTicketSplinterInd.
On Error GoTo Err_cmdEmailReport_Click
Dim lResort As Long, sReportNameSpl As String, sReportNameInd As String lResort = Me.txtResortID
'Check to see if you have a proper resort number. If Nz(DLookup("ReportName", "tblReport", "[Resort#]=" & lResort _ & " AND [ReportNum]=20"), "") = "" Then MsgBox "No Resort Available" Exit Sub
Else
'Dlookup gets the splinter reservation report NAME needed for code 20. sReportNameSpl = DLookup("ReportName", "tblReport", "[Resort#]=" & lResort _ & " AND [ReportNum]=20") End If
'Otherwise, Dlookup gets the Group reservation for 1 person report NAME needed for code 10. sReportNameInd = DLookup("ReportName", "tblReport", "[Resort#]=" & lResort _ & " AND [ReportNum]=10")
If Not IsNull(Forms![frmReservation]!txtSplinterDateIN) Then DoCmd.OpenReport sReportNameSpl, acViewPreview
Else DoCmd.OpenReport sReportNameInd, acViewPreview 'Put email send object here ?????? also need to tell it is automatically a PDF format. How? DoCmd.SendObject acReport, stDocName, acFormatPDF Exit_cmdEmailReport_Click: Exit Sub
Err_cmdEmailReport_Click: MsgBox Err.Description Resume Exit_cmdEmailReport_Click End If |
|