Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2012

    Unanswered: Sending report to tray two with vba...kind of working

    Basically I have code that runs and update query and prints a report based on that data. Before the code runs a message box pops up asking the user if they really want to run the update. When the report prints it should send to tray two. My code is below and Im getting error "The number you used to refer to the report is invalid". Is my IF statement not right?

    Private Sub cmdPrintIRTags_Click()
    On Error GoTo Err_cmdPrintIRTags_Click
    'Message box confirming update
    If MsgBox("Inventory Reduction Update?", vbYesNo, "DSW Inventory Reduction") = vbYes Then
    'turn off warnings
    DoCmd.SetWarnings (warningsfalse)
    'run an update query
    DoCmd.OpenQuery "qryDSWInventoryReductionUpdate"
    'open the report that views the data from the update query
    DoCmd.OpenReport "rptInventoryReductionSignsNew", acWindowNormal
    If Application.Printer.DeviceName Like "*HP LJ300-400*" Then
        'Set the report destination paper bin to Tray 2
        'Use number not name, cannot exceed 250
        Reports(rptInventoryReductionSignsNew).Printer.PaperBin = 2
    End If
    DoCmd.PrintOut acPrintAll
    DoCmd.Close acReport, rptInventoryReductionSignsNew, acSaveNo
    DoCmd.SetWarnings (warningson)
        End If
        Exit Sub
        MsgBox Err.Description
        Resume Exit_cmdPrintIRTags_Click
    End Sub
    Edit: I found the code to send it to tray two online and used that code altering it to what i'm trying to do.

  2. #2
    Join Date
    May 2004
    New York State
    DoCmd.OpenReport "rptInventoryReductionSignsNew", acWindowNormal
    acWindowNormal is a default setting, and you don't need to say it at all. Simply say
    DoCmd.OpenReport "rptInventoryReductionSignsNew"
    Besides, if you do want to change the window mode, you would need 4 commas, as in
    DoCmd.OpenReport "rptInventoryReductionSignsNew", , , , acWindowNormal
    Please see the OpenReport method in the help file for explanation.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts