DoCmd.OpenReport "Invoice", acPreview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gazza10001
    New Member
    • Jan 2009
    • 2

    #1

    DoCmd.OpenReport "Invoice", acPreview

    Hi

    i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as entry fields and so there is a button you press which then takes to through to a print preview of the invoice and you print out the invoice but recent ly this message ahs started appearing and does not allow you to view the print preview of the invoice and crashes.

    Run Time error 2501

    The OpenReport action was cancelled , and when i debug it it Higghlights this line of the code as the problem

    Private Sub Command183_Clic k()

    'Me.invoicedate .Locked = False
    'Me.invoicedate = Date
    'DoCmd.DoMenuIt em acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    'Me.invoicedate .Locked = True


    If Nz(Me.FeeRequir ed, 0) = 0 Then
    MsgBox "No value to invoice (Fee Due)"
    Else

    '''
    DoCmd.SetWarnin gs False
    DoCmd.OpenQuery "AltAddress 0"
    DoCmd.OpenQuery "AltAddress 1"
    DoCmd.SetWarnin gs True

    If Forms![mainMENU]![teamleader] = -1 Then
    If Forms![TBSV]![Terms] <> 417 Then
    If Me.InvoiceDate & "x" = "x" Then
    Me.InvoiceDate = Me.PaymentDate
    End If
    Else
    If Me.InvoiceDate & "x" = "x" Then Me.InvoiceDate = Date
    End If
    DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    End If
    DoEvents
    '''
    'If Me.invoicedate & "x" = "x" Then
    ' MsgBox "No Invoice Date"
    'Else
    If Nz(Me.Multiple, 0) = 0 Then
    DoCmd.OpenRepor t "Invoice", acPreview
    Else
    Dim ANS As Integer
    ANS = MsgBox("Multipl e Instruction Invoice?", vbYesNoCancel, "TBSV")
    If ANS = 6 Then DoCmd.OpenRepor t "Invoice", acPreview
    If ANS = 7 Then DoCmd.OpenRepor t "Invoice", acPreview

    'vbOK 1 OK
    'vbCancel 2 Cancel
    'vbAbort 3 Abort
    'vbRetry 4 Retry
    'vbIgnore 5 Ignore
    'vbYes 6 Yes
    'vbNo 7 No

    End If

    'End If

    End If

    End Sub

    Can anyone help regarding this please as it is driving me up the wall i have posted the entire code to see if there is a problem in there.

    Thanks
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    The opening of the report was cancelled for some reason.
    Not sure if this would apply because it is being opened as a preview but try checking out the printer.
    Is it connected and on?
    Can the computer running the db print a test page to it?

    Just a stab in the dark.
    I wouldn't suspect the code unless you have reason to believe it might have been changed recently!

    Comment

    • DonRayner
      Recognized Expert Contributor
      • Sep 2008
      • 489

      #3
      Access requires the print spooler service to be running to even preview a report. I've had this problem before and all I've done is restart the service to fix it.

      Comment

      • gazza10001
        New Member
        • Jan 2009
        • 2

        #4
        how would i go about resetting the print spooler service in access or on my computer im afraid i am not that technically gifted.

        Comment

        • DonRayner
          Recognized Expert Contributor
          • Sep 2008
          • 489

          #5
          If you are using XP, click the start button then select Run. In the run window type services.msc and click OK.

          If it's Vista, click the start button and type services.msc into the search box at the bottom and press return

          In the Services window scroll down until you find the Print Services service, right click on it and select restart from the menu.

          Comment

          Working...