Results 1 to 8 of 8
  1. #1
    drhansenjr is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    14

    The expression On Load you entered as the event property setting produced the following error...

    I am getting these errors immediately after opening a form in form view -- but it worked fine until recently and I'm not sure what change(s) caused the errors:




    The expression On Load you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name.


    ...and...


    The expression On Current you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name.


    Any ideas? Code follows:


    My Form_Load is...




    Code:
    Private Sub Form_Load()
    On Error GoTo Error_Handler
    Call appInit
    DoCmd.GoToRecord , , acFirst
    Error_Handler_Exit:
    On Error Resume Next
    Exit Sub
    Error_Handler:
    Call showError
    Resume Error_Handler_Exit
    End Sub
    ...and my Form_Current is...

    Code:
    Private Sub Form_Current()
    On Error GoTo Error_Handler
    Dim rstSpouse1Query As Recordset
    Dim rstSpouse2Query As Recordset
    Dim strSpouse1SQL As String
    Dim strSpouse2SQL As String
    Dim rstFemaleNameLookup As Recordset
    Dim rstMaleNameLookup As Recordset
    Dim rstCollectionQuery As Recordset
    Dim qdfSpouse1Query As QueryDef
    Dim qdfSpouse2Query As QueryDef
    Dim qdfFemaleMembers As QueryDef
    Dim qdfMaleMembers As QueryDef
    Dim qdfFemaleNameLookup As QueryDef
    Dim qdfMaleNameLookup As QueryDef
    Dim qdfCollectionQuery As QueryDef
    Dim lngCurrRec As Long
    Dim lngFirstSpouseID As Long
    Dim lngSecondSpouseID As Long
    Dim lngFirstMarriagePhotoCollectionID As Long
    Dim strSqlGetPhotoCollectionPrefix
    Dim lngSecondMarriagePhotoCollectionID As Long
    Dim strCollTbl As String
    Dim strSQLWhere As String
    varCurrentMemberID = Me.CurrentRecord
    If IsNull(varCurrentMemberID) Or IsNull(Me.CurrentRecord) Then
    DoCmd.GoToRecord acDataForm, "frmMembers2", acFirst
    varCurrentMemberID = Me.CurrentRecord
    Me.Refresh
    End If
    dirtyForm = False
    Me!btnSave.Enabled = False
    Me!btnUndo.Enabled = False
    If Not (IsNull(Me.cbGenderSelect)) Then
    Call showCollection(Me.ID, Me.cbGenderSelect)
    End If
    If Me.cbGenderSelect = "M" Then
    Me.cbFirstSpouseSelect.RowSourceType = "Table/Query"
    Me.cbFirstSpouseSelect.RowSource = "qryGetFemaleIDsAndFullNames"
    ElseIf Me.cbGenderSelect = "F" Then
    Me.cbFirstSpouseSelect.RowSourceType = "Table/Query"
    Me.cbFirstSpouseSelect.RowSource = "qryGetMaleIDsAndFullNames"
    Else
    Me.cbFirstSpouseSelect.RowSource = ""
    End If
    Set rstSpouse1Query = Nothing
    Set rstSpouse2Query = Nothing
    If Not (IsNull(Me.cbGenderSelect)) Then
    Call showCollection(Me.ID, Me.cbGenderSelect)
    End If
    'Populate Family Photo Collection fields
    Error_Handler_Exit:
    On Error Resume Next
    Exit Sub
    Error_Handler:
    Call showError
    Resume Error_Handler_Exit
    End Sub
    These also call my appInit and showError subs:


    Code:
    Public Sub appInit()
    On Error GoTo Error_Handler
    Set CurrDB = CurrentDb
    Forms("frmMembers2").btnSearch.Enabled = False
    Forms("frmMembers2").tbSearch = ""
    'Forms("frmMembers2").lbSearch.RowSource = ""
    Error_Handler_Exit:
    On Error Resume Next
    Exit Sub
    Error_Handler:
    Call showError
    Resume Error_Handler_Exit
    End Sub
    and


    Code:
    Public Sub showError()
    Dim strError As String
    Dim intMsgRet As Integer
    strError = "The following error has occurred" & vbCrLf & vbCrLf & _
    "Error Number: " & Err.Number & vbCrLf & _
    "Error Description: " & Err.Description & _
    "Line: " & Erl
    intMsgRet = MsgBox(strError, vbOKOnly + vbCritical, "An Error has Occurred!")
    End Sub
    Help appreciated!

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,111
    Do you have a procedure called Error_Handler (it should just be a label inside the other procedures)?
    EDIT: sorry didn't see all the code inside those tiny code windows in your initial post. Could you try to decompile the project and see if you then find any compile errors? Any missing references?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,906
    Is that the code version of keyhole surgery?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,404
    This sounds like a rare form of corruption: dis-association of a form from its code module.
    If that's the correct diagnosis, the fix:
    In VBE go to the forms code module. CTRL+A to select it all, CTRL+C to copy to clipboard.
    Open the form in design mode, Property sheet OTHER, set Has Module = NO, then Are you sure, click YES
    Save and close the form.
    Open form in design view, on ribbon choose Design, then View Code
    The VBE will pop up an empty window. CTRL+C to paste in the previously copied code.
    Save, debug, compile.

    If you don't follow this, or are reluctant, Upload your DB here and we can determine if the diagnosis is correct and apply fix OR analyze if diagnosis is incorrect.

  5. #5
    drhansenjr is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    14
    Unfortunately that did not solve the problem.

  6. #6
    drhansenjr is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    14
    Quote Originally Posted by Gicu View Post
    Do you have a procedure called Error_Handler (it should just be a label inside the other procedures)?
    EDIT: sorry didn't see all the code inside those tiny code windows in your initial post. Could you try to decompile the project and see if you then find any compile errors? Any missing references?
    No joy. When I compile I get this:

    Click image for larger version. 

Name:	misc3.jpg 
Views:	22 
Size:	33.1 KB 
ID:	44983

  7. #7
    drhansenjr is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    14
    Proble solved. My form module was declared as

    Code:
    Private Sub tbSearch_Dirty()
    rather than

    Code:
    Private Sub tbSearch_Dirty(Cancel As Integer)
    One I fixed that the error went away.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    These form procedures are in the form module and not a standard module, yes?
    Rather than remove a whole module, I prefer to click the property sheet ellipses for the event in case it became disconnected.
    Based on the compile error message, I see no proof that it relates to the procedures you posted, so perhaps you fixed the entire module but still have one somewhere that's not right. Make sure you didn't add a parameter to an event that doesn't accept it, or accept it as written.
    e.g.
    private sub form_open("test")
    instead of
    private sub form_open(cancel as integer)

    An odd example perhaps, but it's just meant to get a point across
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-08-2020, 11:17 AM
  2. Replies: 21
    Last Post: 07-26-2018, 11:50 AM
  3. Replies: 10
    Last Post: 03-22-2018, 01:37 AM
  4. Replies: 18
    Last Post: 12-15-2016, 02:17 PM
  5. Replies: 7
    Last Post: 05-08-2014, 10:34 AM

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