Button on Access 2013 form to print report using current data on entry form and then save report as PDF
Posted on 2014-09-17
Hi all, I am a complete Novice with Access and this is actually the second question I have posted to try to figure out my Access 2013 problem. First, I'll explain what I have done, what is the result, and then where I need to be with this. Thank you in advance for your help.
I have created a one table database that uses an entry form to create records. Once I had the form working I designed a simple report to output a single record, the current record showing on the form, to a letter size label using a 'Print' button at the bottom of the form. This part I have working and the PrintCurrent_Click() code behind the button I have used is show below.
Private Sub PrintCurrent_Click()
'Print current record
Me.Dirty = False
If IsNull(Me!ID) Then
MsgBox "Please select a valid record", _
DoCmd.OpenReport "JobTicket", acViewNormal, , "ID =" & Me.ID
Now as I said this code will print out the newly entered record on the screen in the form correctly. What I have to add to this is code that will allow me to save the report with the same newly entered data from the displayed form to the Desktop as a PDF file named using the 'Jobnum' field from the same newly entered data. This is where I run into problems. I have not been able to successfully and without error save the report as 'Jobnum value'.PDF to the desktop. I can't seem to get the current data from the screen to be saved. I keep getting one pdf that has a report page for every record in the database. I hope I have explained this thoroughly for you. Thank you for your help!