I am looking for a way to be able to enter data into fields on a form, then be able to e-mail a report that shows only that record.
This is what I have thus far:
At the end of my Form, I have a Command Button. Right now the Command Button has an On Click... [Event Procedure] to basically E-mail a Report.
Here is my Visual Basic code for it:
Expand|Select|Wrap|Line Numbers
- Private Sub Mail_Report_Button_Click()
- On Error GoTo Err_Mail_Report_Button_Click
- Dim stDocName As String
- stDocName = "TrainingRequestSingle"
- DoCmd.SendObject acReport, stDocName
- Exit_Mail_Report_Button_Click:
- Exit Sub
- Err_Mail_Report_Button_Click:
- MsgBox Err.Description
- Resume Exit_Mail_Report_Button_Click
- End Sub
However, this Report that ends up being e-mailed has all of the Records the Form has total.
I want to to be able to click the Command Button to E-mail the Report which would then show only the current Record being viewed on the Form.
I have another Command Button on the same Form that Prints the current Record only (and not all Records) with success. I have tried manipulating it to work for my E-mailing situation with no success, however.
Here is the Visual Basic code I used in that situation:
Expand|Select|Wrap|Line Numbers
- Private Sub Print_Record_Button_Click()
- On Error GoTo Err_Print_Record_Button_Click
- DoCmd.OpenReport "TrainingRequestSingle", acViewPreview, , _
- "[TrainingRequestID]=Forms![Training Request Form]!TrainingRequestID"
- Exit_Print_Record_Button_Click:
- Exit Sub
- Err_Print_Record_Button_Click:
- MsgBox Err.Description
- Resume Exit_Print_Record_Button_Click
- End Sub
Training Request Form
The name of my report is:
TrainingRequestSingle
The name of my e-mail report command button is:
Mail Report Button
I am using Microsoft Access 2002.