Results 1 to 3 of 3
  1. #1
    Ina is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2021

    Procedure declaration does not match description of event or procedure

    I am getting this error when I attempt to opening a report in print preview:

    The expression On Open ...............Procedure declaration does not match ...
    This is the code I run when I run the report.

    Public Sub NewAge()
    CurrentAge = Null
    BirthDate = Nz(DLookup("BirthDate", "DogT", "DogID=" & DogID), 0)
    If IsNull(BirthDate) Then Exit Sub
    CurrentAge = HowLong(BirthDate, True, "ym", False, False)
    End Sub

    Private Sub Report_Open()
    End Sub

    I use this same procedure in a form without an issue. I've also done a Debug Compile.

    Any help would be greatly appreciated.

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Why test birthdate for null when your setting it to 0 if null in the line before?
    Not sure what effect 0 would have on your HowLong function.

    Have you tried other events like onload?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    Ajax is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    currentAge and BirthDate don't appear to have been declared (unless these are controls on your report) - I also suspect you don't have Option Explicit at the top of your module which would enable you to see these things before you run your code

    you are also calling the function HowLong, but it doesn't appear to exist in what you have provided

    And it is referencing DogID (again might be a variable, might be a control). If it is a control, it's value will not be available until the report Load or current event, So try moving your code to one of these events.

    Agree with Moke - your Birthdate will never be null because of the prior use of the nz function so you will never exit sub at that point

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Event Procedure Doing Nothing
    By DMT Dave in forum Access
    Replies: 13
    Last Post: 07-23-2021, 01:19 AM
  2. Replies: 33
    Last Post: 09-25-2015, 08:39 AM
  3. Event procedure
    By vugar in forum Access
    Replies: 3
    Last Post: 09-09-2014, 11:36 PM
  4. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  5. Replies: 3
    Last Post: 05-07-2012, 12:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Other Forums: Microsoft Office Forums