Sniper-BoOyA-
Registered User.
- Local time
- Today, 07:24
- Joined
- Jun 15, 2010
- Messages
- 204
Good Afternoon people,
I am trying to get a hand of a few things when it comes to Access and VBA. There is just one thing i can not seem to figure out.
Ive got a database which is made by a man who is no longer with us, and he made a button which opens a report, gives the printer an order to print it, and also saves the report as a pdf file.
The code beind that button is:
What i am trying to do is to split the 2 functions and make one button to print it, and one button to save it as a pdf. But i cant seem to understand what happends in this code.
Is there anyone who is so kind to explain it a little bit so i can split the thing?
Cheers!
I am trying to get a hand of a few things when it comes to Access and VBA. There is just one thing i can not seem to figure out.
Ive got a database which is made by a man who is no longer with us, and he made a button which opens a report, gives the printer an order to print it, and also saves the report as a pdf file.
The code beind that button is:
Code:
Private Sub cmdafdrtoetsN1_Click()
On Error GoTo Err_cmdafdrtoetsN1_Click
Dim prt As Printer
Dim i As Long
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim strNaam As String
Dim strSubPad As String
Dim strPad As String
Dim strRapport As String
Set db = CurrentDb
Set rst = db.OpenRecordset("contact", dbOpenDynaset)
strRapport = "raptoetsingN1"
Set prt = Application.Printer
Application.Printer = Printers("PDFCreator")
'patch which will be used to save the .pfd
'(Folder current database)
'strPad = CurrentProject.Path
PDF_Start
strNaam = rst!opdrachtnr
strSubPad = Left(strNaam, 2)
strPad = "G:\" & strSubPad & "\" & strNaam & "\" & "Acrobat\"
strNaam = "LS_Asfalt_Toetsing_(N1)" & strNaam
If AfdrukkenRapport(strRapport, strNaam, strPad) = 1 Then
rst.MoveNext
Else
End If
PDF_Stop
Application.Printer = prt
DoCmd.OpenReport strRapport, acViewNormal
Exit_cmdafdrtoetsN1_Click:
Exit Sub
Err_cmdafdrtoetsN1_Click:
MsgBox "Fout: " & Err.Number & vbNewLine & Err.Description, vbExclamation, "cmdafdrtoetsN1_Click"
Resume Exit_cmdafdrtoetsN1_Click
End Sub
What i am trying to do is to split the 2 functions and make one button to print it, and one button to save it as a pdf. But i cant seem to understand what happends in this code.
Is there anyone who is so kind to explain it a little bit so i can split the thing?
Cheers!