Procedure declaration does not match description of event or procedure

  • Thread starter Thread starter Paul Camilleri
  • Start date Start date
P

Paul Camilleri

I have a database for church records in Access 2002. It
is set up to run as Access 200 for compatibility with the
church computer. On running the following code:

Private Sub FindBox_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ParishionerID] = " & Str(Nz(Me!
[FindBox], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

I get an error message "Procedure does not match the
description of events or procedures having the same name."

I have no idea how to get this to work. I would be
grateful for any help
 
You have a combo (or text box) named "FindBox". Make sure there is no other
Sub or Function named FindBox_AfterUpdate in the same module, or a Public
FindBox procedure in any other module.

Next, make sure that FindBox is unbound (nothing in its ControlSource
property). You will not be able to move to another record if it is altering
a field of the current record. In fact, it is a good idea to explicitly save
before moving the record if it is dirty.

It's always best to typecast as tightly as possible, so assuming this data
is stored in Access tables, declare a Recordset variable from the DAO
library. Then use the RecordsetClone of the form, rather than a Clone of the
Recordset (which may be the bit that is triggering this problem.)

Finally, after a Find, you need to test NoMatch, not EOF.

Try something like this:

Private Sub FindBox_AfterUpdate()
Dim rs As DAO.Recordset

If Me.Dirty Then 'save first.
Me.Dirty = False
End If

Set rs = Me.RecordsetClone
rs.FindFirst "[ParishionerID] = " & Str(Nz(Me![FindBox], 0))
If rs.NoMatch Then
MsgBox "Not found."
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End Sub


(We have assumed that ParishionerID is a Number type field, not Text. You
would need extra quotes for a Text field.)
 
By trial and error, I discovered that another Private Sub
which was called on the OnOpen event was causing the
problem. I was able to alter that sub and everything is
now working properly.

Thank you for your help.

Paul Camilleri
 
Back
Top