I fist ask this in a different forum but did not get an asnser so rewritting my question.
I have a form in access 2003 on a XP(sp3) computer. It has a number of printers attached to the network. The code below will select all reports,in the text box. It will populate the combobox with the list of printer available.. BUT in the papersize combo box it only display a 1. I have tried using the VLng with it has a error. so have pasted code for form. Can someone please explain the issue please.
Never give up never give in.
There are no short cuts to anything worth doing
I have a form in access 2003 on a XP(sp3) computer. It has a number of printers attached to the network. The code below will select all reports,in the text box. It will populate the combobox with the list of printer available.. BUT in the papersize combo box it only display a 1. I have tried using the VLng with it has a error. so have pasted code for form. Can someone please explain the issue please.
Code:
Option Compare Database
Private Sub cmdApplyChanges_Click()
If CurrentProject.AllReports(Me![strSelectReport]).IsLoaded Then
With Reports(Me![strSelectReport]).Printer
.PaperSize = Me![CmoPaperSize]
.Orientation = Me![fraOrientation]
End With
Else
MsgBox "Please preview the report first."
End If
End Sub
Private Sub cmdPreview_Click()
' Variable to hold the printer object to manipulate.
Dim prt As Printer
' Grab the printer object for the selected printer.
Set prt = Application.Printers(Me!CmoPrinter.Value)
' Read user-specified settings.
prt.PaperSize = Me![CmoPaperSize]
prt.Orientation = Me![fraOrientation]
' Open the report in preview mode.
DoCmd.OpenReport Me![strSelectReport], acViewPreview
' Set the report's printer to the modified printer object.
Reports(Me![strSelectReport]).Printer = prt
End Sub
Private Sub cmdPrint_Click()
' Check if the report is open.
If CurrentProject.AllReports(Me![strSelectReport]).IsLoaded Then
' Print report if already open.
DoCmd.OpenReport Me![strSelectReport], acViewNormal
Else
' Set up the application printer with custom settings.
Application.Printer = Application.Printers(Me![CmoPrinter].Value)
Application.Printer.PaperSize = Me![CmoPaperSize]
Application.Printer.Orientation = Me![fraOrientation]
' Open and print the report using the new application-level printer settings.
DoCmd.OpenReport Me![strSelectReport], acViewNormal
' Reset the application printer as the default.
Set Application.Printer = Nothing
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim myprinter As Printer
Dim strReport As String
Dim CmoPrinter As Access.ComboBox
' Variable to hold the default printer index.
Dim strDefaultPrinter As String
' Variable to hold the printer object.
'Dim prt As Printer
' Variable to hold the report object while cycling
' through the AllReports collection.
Dim accObj As AccessObject
' Fill the printer list.
' Make sure the RowSource is empty.
Me![CmoPrinter].RowSource = ""
Me![strSelectReport].RowSource = ""
' Cycle through the printers installed on the machine and add them to the combo box.
For Each myprinter In Application.Printers
' Use the new AddItem method to add the printer name to the combo box.
Me![CmoPrinter].AddItem myprinter.DeviceName
Next
' Remember the default printer.
strDefaultPrinter = Application.Printer.DeviceName
' Set the combo box to the default printer.
Me![CmoPrinter] = strDefaultPrinter
Me![CmoPaperSize].Value = 1
' Fill the report list.
For Each accObj In CurrentProject.AllReports
Me![strSelectReport].AddItem accObj.Name
Next
' Set the list box to the first report.
Me![strSelectReport].SetFocus
Me![strSelectReport].ListIndex = 0
'strReport = Me![strSelectReport]
'Set myprinter = Application.Printers(CLng(Me![CmoPrinter]))
'myprinter.PaperSize = Me![CmoPaperSize]
'myprinter.Orientation = Me![fraOrientation]
'Reports(strReport).Printer = myprinter
End Sub
Never give up never give in.
There are no short cuts to anything worth doing