Hi
I'm using access 2007 and I have over 20 forms that are bound to their respective tables. When a save button I made is pressed I want the record to save in the table and the current individual record to save as a pdf in form view. Right now it saves as a record in the table but the pdf saves with all of the records in form view under a single pdf name so I have 40 records in one file. i know that i should make a report and I am totally willing to do that if the report doesnt have to be clicked on or anything to make it save as a pdf. The users know nothing about access so I want it to be just this one button click. Here is what I have to save the forms as pdf. Any help would be appreciated:
-------------------------------------------------------
Thanks!!!
I'm using access 2007 and I have over 20 forms that are bound to their respective tables. When a save button I made is pressed I want the record to save in the table and the current individual record to save as a pdf in form view. Right now it saves as a record in the table but the pdf saves with all of the records in form view under a single pdf name so I have 40 records in one file. i know that i should make a report and I am totally willing to do that if the report doesnt have to be clicked on or anything to make it save as a pdf. The users know nothing about access so I want it to be just this one button click. Here is what I have to save the forms as pdf. Any help would be appreciated:
Code:
Private Sub Save_Click()
On Error GoTo save_record_Click_Err 'this is the button click
On Error Resume Next
If IsNull(Me.Person_Performing_the_Work) Then
MsgBox "Please fill out the person performing work field"
Cancel = True
Else
DoCmd.RunCommand acCmdSaveRecord
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
DoCmd.GoToRecord acActiveDataObject, "Form Name", acLast
'this calls the save pdf function below
SaveToPDF ("Expendable Form")
-------------------------------------------------------
Code:
Public Function SaveToPDF(SrcFile As String)
On Error GoTo SaveToPDF_Err
'SrcFile = name of report the function was called from, as generated by Screen.ActiveForm.Name
'DestPath = Destination path for PDF file
Dim DestPath As String
'DestFile = Destination file name for PDF file
Dim DestFile As String
'ShowPdf = launch acrobat and display saved PDF file
Dim ShowPdf As Boolean
'Saves the file to specific folder(this is not my real path)
DestPath = "Documents\Practice Save\"
'Formats the file name
DestFile = Month(Now) & "_" & Day(Now) & "_" & Year(Now) & "_" & [Manufacturer's S/N]
ShowPdf = False
Dim strDestFile As String
strDestFile= DestPath & DestFile & ".pdf"
DoCmd.OutputTo acOutputForm, , acFormatPDF, strDestFile, False
SaveToPDF_Exit:
Exit Function
SaveToPDF_Err:
Resume SaveToPDF_Exit
End Function
Thanks!!!