Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Printing report from form info (97)

    Hi all,
    I have a form that after I fill in all the fields on the record, I would like to preview the report then print it. I have a command button on the form with the following code:
    Private Sub preview_check_Click()
    On Error GoTo Err_preview_check_Click

    Dim stDocName As String

    stDocName = "rptCheck1"
    DoCmd.OpenReport stDocName, acPreview, , "number=" & Me.Number
    RunCommand acCmdFitToWindow


    Exit_preview_check_Click:
    Exit Sub

    Err_preview_check_Click:
    MsgBox Err.Description
    Resume Exit_preview_check_Click

    End Sub

    If I try to click the button when I finish with the last field I get an error message: run time error 255. The expression'|' you entered is invalid.
    If I go to a new record then go back to this record it works fine.
    Do I need a line of code to save this record before I preview it?
    Thanks in advance. John

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing report from form info (97)

    Insert this code to save the record:
    ...
    Dim stDocName As String
    If Me.Dirty Then
    DoCmd.RunCommand acCmdSaveRecord
    End If

    stDocName = "rptCheck1"
    ...
    Francois

  3. #3
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Printing report from form info (97)

    Thank you for your help Francois and all the help you have provided on this site.
    John

Posting Permissions

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