Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Extra ) Error message (Access 2003/SP 1)

    Hi all. I am having trouble with an OnClick event. I copied the code from a different Form that works perfectly and changed just the report name that I want it to open. Following is the code and attached is the error message I am getting.

    Private Sub PrChecklist_Click()
    On Error GoTo Err_PrChecklist_Click
    Dim stDocName As String
    stDocName = "USA Orders Checklist"
    DoCmd.OpenReport stDocName, acViewPreview, , "OrderID=" & Me.OrderID
    Exit_PrChecklist_Click:
    Exit Sub
    Err_PrChecklist_Click:
    MsgBox Err.Description
    Resume Exit_PrChecklist_Click
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Extra ) Error message (Access 2003/SP 1)

    The error message means that Me.OrderID was null (blank) when PrCheckList was clicked. I assume that you don't want to open the report if OrderID is null. You can check for this at the beginning of the code:

    If IsNull(Me.OrderID) Then
    MsgBox "Create an order before opening the report"
    Exit Sub
    End If

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Extra ) Error message (Access 2003/SP 1)

    Thanks. I have code that when my form opens, it goes to a new empty record. I wanted to test the command button and just quickly clicked on it. When you say put it at the beginning of the code, do I place it right underneath "Private Sub PrChecklist_Click()"?

    Never mind. I figured it out. The little code I know is like a half a drop of rain in a bucket and I'm always concerned about messing things up badly and can't figure them out.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Extra ) Error message (Access 2003/SP 1)

    You may also want to add the following immediately above the line that opens the report:

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If

    These lines save the current record if it is new or has been changed. This is necessary since the report looks at the saved version of the record.

  5. #5
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Extra ) Error message (Access 2003/SP 1)

    Ok, thanks a lot.

Posting Permissions

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