command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a command button set up to print reports to pdf. I have three
different types of info that it is based on. I have a field on the form
"PumpType". If pump type = PumpA, I want it to print report rPumpAReport.
If pump type = PumpB, print report rPumpBReport. For anything not Pump A or
B, print rReportX. I can get the first two with code:
DoCmd.Requery "JobNumber"
If Me.PumpType = "PumpA" Then
Set Application.Printer = Application.Printers("CutePDF Writer")
DoCmd.OpenReport "rPumpAReport"
Set Application.Printer = Nothing
DoCmd.Requery "JobNumber"
ElseIf Me.PumpType = "PumpB" Then
Set Application.Printer = Application.Printers("CutePDF Writer")
DoCmd.OpenReport "rPumpBReport"
Set Application.Printer = Nothing

How do I enter code for If Not Pump A or Pump B, print Report X? And, is
there a way to requery the form without entering Requery.JobNumber at each
entry. The form is based on JobNumber being an autonumber field.
Originally, it was set up to enter all info and then a macro to Show All
Records, this would prompt for job number, select command button to print
report and then enter job number again. I'm trying to do all this without
entering job number twice.
Any help is greatly appreicated!!
PHisaw
 
If Me.PumpType = "PumpA" Then
Set Application.Printer = Application.Printers("CutePDF Writer")
DoCmd.OpenReport "rPumpAReport"
Set Application.Printer = Nothing
DoCmd.Requery "JobNumber"
ElseIf Me.PumpType = "PumpB" Then
Set Application.Printer = Application.Printers("CutePDF Writer")
DoCmd.OpenReport "rPumpBReport"
Set Application.Printer = Nothing
Else
Set Application.Printer = Application.Printers("CutePDF Writer")
DoCmd.OpenReport "Report X"
Set Application.Printer = Nothing
End If
 
Thank you Douglas for the quick reply - you made it seem very simple. What
about the requery to have the new info on the report?
 
Back
Top