Event Procedure

G

Guest

Hello group,

Can anyone tell me what's wrong with Event. I'm getting the following erro
message Compil error: User-defined type not defined. I have Access 2000

Thanks in advance


Private Sub Form_Open(Cancel As Integer)

' 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!cmbPrinter.RowSource = ""
Me!lbxSelectReport.RowSource = ""

' Cycle through the printers installed on the machine and add them to the
combo box.
For Each prt In Application.Printers
' Use the new AddItem method to add the printer name to the combo box.
Me!cmbPrinter.AddItem prt.DeviceName
Next

' Remember the default printer.
strDefaultPrinter = Application.Printer.DeviceName

' Set the combo box to the default printer.
Me!cmbPrinter = strDefaultPrinter
Me!cmbPaperSize = 1

' Fill the report list.
For Each accObj In CurrentProject.AllReports
Me!lbxSelectReport.AddItem accObj.Name
Next

' Set the list box to the first report.
Me!lbxSelectReport.SetFocus
Me!lbxSelectReport.ListIndex = 0

End Sub
 
D

Dirk Goldgar

Antonio said:
Hello group,

Can anyone tell me what's wrong with Event. I'm getting the
following erro message Compil error: User-defined type not defined. I
have Access 2000

Thanks in advance


Private Sub Form_Open(Cancel As Integer)

' 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!cmbPrinter.RowSource = ""
Me!lbxSelectReport.RowSource = ""

' Cycle through the printers installed on the machine and add them to
the combo box.
For Each prt In Application.Printers
' Use the new AddItem method to add the printer name to the combo box.
Me!cmbPrinter.AddItem prt.DeviceName
Next

' Remember the default printer.
strDefaultPrinter = Application.Printer.DeviceName

' Set the combo box to the default printer.
Me!cmbPrinter = strDefaultPrinter
Me!cmbPaperSize = 1

' Fill the report list.
For Each accObj In CurrentProject.AllReports
Me!lbxSelectReport.AddItem accObj.Name
Next

' Set the list box to the first report.
Me!lbxSelectReport.SetFocus
Me!lbxSelectReport.ListIndex = 0

End Sub

I don't think Access 2000 has the Printers collection and Printer
object. I believe they were introduced wth Access 2002.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top