XelaIrodavlas
Registered User.
- Local time
- Today, 05:25
- Joined
- Oct 26, 2012
- Messages
- 175
Hi All,
I've been asked to put together a function that prints two different reports and up to two hyperlinked documents on our network (based on a selected combo box item).
The idea is to save users from having to locate each report individually - Easy enough I thought, I just tell access where to find each report, and print without opening the dialog box for any of them. See code below.
This works ok, except when printing this way, it prints each report to whatever printer/settings were chosen the last time that report was printed, which can be different every time, this is resulting in very odd events such as two reports sent to printer, and one to the pdf writer, or one report from one printer, and the others from down the hallway!
This may be a big ask, but does anyone know if its possible to open the print dialog menu once, and then apply the selected settings to the other two reports as well?
I'm currently toying with application.filedialog but this is very new ground for me...
Any help appreciated
Alex S
I've been asked to put together a function that prints two different reports and up to two hyperlinked documents on our network (based on a selected combo box item).
The idea is to save users from having to locate each report individually - Easy enough I thought, I just tell access where to find each report, and print without opening the dialog box for any of them. See code below.
Code:
Private Function PrintAllDocs()
'Print the Selected WPS, Weld Card, and Associated WPAR's
If Len(Me!Combo74 & vbNullString) = 0 Then Exit Function 'do nothing if none chosen
mResponse = MsgBox("This will print a Weld Card, WPS, and any related WPAR's for the selected WPS." & vbCrLf & vbCrLf & _
"Note: This will print from the last known printer for each form." _
, vbYesNo + vbInformation, "Caution")
If mResponse <> vbYes Then Exit Function
'1. Print Weld Card (As per normal button):
DoCmd.Close acReport, "A4CustomWPSGrid"
DoCmd.Close acReport, "A4CustomWPSNoGrid"
If Me!Option76 = True Then
DoCmd.OpenReport "A4CustomWPSGrid", acViewNormal, "RevisionID = " & Me!Combo78 'Grid
Else
DoCmd.OpenReport "A4CustomWPSNoGrid", acViewNormal, , "RevisionID = " & Me!Combo78 'No Grid
End If
'2. Print The WPS
DoCmd.Close acReport, "WPSNoWeldCard"
DoCmd.OpenReport "WPSNoWeldCard", acViewNormal, , "RevisionID = " & Me!Combo78
'3. Find, Open and Print the WPAR PDF(s)
Dim vLink As String
Dim MyBrowser As SHDocVw.InternetExplorer
Set MyBrowser = New SHDocVw.InternetExplorer
If Len(Me!Combo74.Column(2) & vbNullString) <> 0 Then 'Check first WPARID field is not null
DoCmd.OpenForm "WPARNew", , , "WPARID = " & Me!Combo74.Column(2)
If Len(Forms!WPARNew!Text77 & vbNullString) <> 0 Then 'Check there is a hyperlink to this WPAR.
vLink = HyperlinkPart(Forms!WPARNew!Text77, acAddress)
'display the file
'MyBrowser.Visible = True
'MyBrowser.Navigate vLink
'print it
ExecuteFile vLink, PrintFile
Else
MsgBox "Error finding Scan of WPAR " & Forms!WPARNew!Text38
End If
DoCmd.Close acForm, "WPARNew"
End If
'3a. If Second WPARID field is not null then repeat for that
If Len(Me!Combo74.Column(3) & vbNullString) <> 0 Then 'Check first WPARID field is not null
DoCmd.OpenForm "WPARNew", , , "WPARID = " & Me!Combo74.Column(3)
If Len(Forms!WPARNew!Text77 & vbNullString) <> 0 Then 'Check there is a hyperlink to this WPAR.
vLink = HyperlinkPart(Forms!WPARNew!Text77, acAddress)
'display the file
''MyBrowser.Visible = True
''MyBrowser.Navigate vLink
'print it
ExecuteFile vLink, PrintFile
Else
MsgBox "Error finding Scan of WPAR " & Forms!WPARNew!Text38
End If
DoCmd.Close acForm, "WPARNew"
End If
DoCmd.Close acForm, "PrintFrm"
End Function
This may be a big ask, but does anyone know if its possible to open the print dialog menu once, and then apply the selected settings to the other two reports as well?
I'm currently toying with application.filedialog but this is very new ground for me...
Any help appreciated

Alex S
Last edited: