Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    New Orleans, Louisiana
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subform error message (Access 97 SR-2)

    I linked a main form and a subform using the build button
    and taking the suggested links. But when I go to the
    subform I get an error message that says: "Event
    procedure declaration does not match description of event
    having the same name." What am I doing wrong? I am
    using Access 97 SR-2.

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

    Re: Subform error message (Access 97 SR-2)

    Do you have any code behind the main form or subform? In particular, event handlers for the Before Update or After Update event of the main form, or for the On Current event of the subform?

    If so, can you post the code? (If it is long, save it in a .txt file and attach that to your reply instead of pasting it into the reply itself)

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    New Orleans, Louisiana
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform error message (Access 97 SR-2)

    The only code is behind the main form After Update as follows:

    Private Sub Form_AfterUpdate(Cancel As Integer)

    ' Display message if CustomerName combo box is blank.

    Dim strMsg As String, strTitle As String
    Dim intStyle As Integer

    If IsNull(Me!CustomerName) Or Me!CustomerName = "" Then
    strMsg = "You must pick a value from the Bill To list."
    strTitle = "Bill To Customer Required"
    intStyle = vbOKOnly
    MsgBox strMsg, intStyle, strTitle
    Cancel = True
    End If

    End Sub

    This code was copied from the Northwind example as I don't have experience with code.
    Thanks for your help.

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

    Re: Subform error message (Access 97 SR-2)

    The problem is that Cancel is not an argument of the After Update event but of the Before Update event. The Cancel argument can be set to True to stop the update from being executed. Obviously, this only makes sense before the update has occurred, not afterwards. You can't just change AfterUpdate into BeforeUpdate in Access 97. Copy the body of the procedure (everything except the Private Sub and End Sub lines) to the clipboard, then delete the entire procedure. Next, select Event Procedure from the dropdown list in the Before Update box in the Properties of the form, then click the Builder button (the three dots). Paste the code into the new procedure.

Posting Permissions

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