R/T error 2501

pullmyefinger

Registered User.
Local time
Today, 16:36
Joined
Feb 26, 2011
Messages
37
NEW: the command (next, prev record) buttons don't seem to be the issue. they were commented out and the form still won't Open from the menu OR manually.

WHEN I try to manually run the form i get a message that basically says:

The expression on open as the event property setting produced the following error: Procedure Declaration does not match description of event or procedure having the same name.

there is a main menu that has a cmd button "edit or del records". when i click that button I get the error msg above.

the on open event has one line that says "DoCmd.OpenForm ("Edit")

this worked before, there is a form called Edit, spelled exactly that way. I know you don't always get the statement causing the error all the time, but this is stupid or I did something stupid that I forgot about.
Please look at the code and see what's what? I can't fig it out.




trying to use an edit form that has worked fine with docmd.openform("Edit")

until I realized that the end user won't be looking at the current record or BOF or EOF.

i understand the error message that comes up, but she won't and she will panic. besides, if i can write code to prevent that from happening that is what should be done anyway.

after adding the code below, every time i try to open the form, access gives me the aforementioned error and says the openform action was cancelled. this is the only thing i added, so i need to know if i did something stupid and that is causing the problem??


PS: The form won't open manually or via the code. It keeps saying the on open event "did not resolve" to a vba event or some control and that i need to check spelling. I cannot find anything wrong.


Private Sub NextRecBtn_Click()
Dim currentrec, lastrec As Long, numrows As Integer

Me.Refresh
numrows = DCount("*", "EQPT")
lastrec = numrows
currentrec = frm.CurrentRecord (should be current rec in EQPT table)

If numrows = 1 Then

Me.NextRecBtn.Enabled = False
ElseIf currentrec = numrows Then

Me.NextRecBtn.Enabled = False

Else
Me.NextRecBtn.Enabled = True
DoCmd.RunCommand acCmdRecordsGoToNext
End If
End Sub


All i want to do is to enable/disable the next and previous record command buttons at the appropriate times. my logic is that if the current record is the last record, then disable the next record button. also, if the current record is record 1, disable the previous record button, and if neither condition is true enable both buttons.
 

Attachments

Last edited:
The button wizard has Next Record and Previous Record buttons already coded.
 
This code is bpoilerplate I've used for years in v2000 and v2003:
Code:
Private Sub Form_Load()
  DoCmd.GoToRecord , , acNext
  DoCmd.GoToRecord , , acFirst
End Sub

Private Sub Next_Click()
  If CurrentRecord = RecordsetClone.RecordCount Then
    MsgBox "You are on the Last Record!"
  Else
    DoCmd.GoToRecord , , acNext
  End If
End Sub

Private Sub Previous_Click()
  If CurrentRecord = 1 Then
    MsgBox "You are on the First Record!"
  Else
   DoCmd.GoToRecord , , acPrevious
  End If
End Sub

Linq ;0)>
 
do not have that wizard or add-in for whatever reason. besides, you don't learn anything by letting a wizard do it for you.
 
thanks, but i commented out all that stuff and i still get the error so the buttons don't seem to be it.
 
do not have that wizard or add-in for whatever reason. besides, you don't learn anything by letting a wizard do it for you.
It creates some code from which you can learn. The wizard is definitely there, just drop a button on your form and it starts up with the wizard.

thanks, but i commented out all that stuff and i still get the error so the buttons don't seem to be it.
That was my initial thought because error 2501 has to do with an action being cancelled (or something along those lines).
 
It creates some code from which you can learn. The wizard is definitely there, just drop a button on your form and it starts up with the wizard.

That was my initial thought because error 2501 has to do with an action being cancelled (or something along those lines).

=====================================================

ok, understand the learning part, but WHAT is causing the 2501 Error?? That's why I attached the db
 
=====================================================

ok, understand the learning part, but what is causing the 2501 error?? That's why i attached the db

========================================================

i get the moron of the week award. What happened is i made a copy of the edit form and called it delete. I just happened to look at the on open event for the del form and i deleted the "cancel as integer" part.. That solves that.
 
Tell me you did not actually nameyour forms Edit and Delete did you? If so, at least prefix then with Frm. As per FrmEdit and FrmDelete. Access might play havoc with your app using names like Edit and Delete.
 
No. No need to do that cuz they both worked fine prior to this and they don't seem to be "reserved words" or whatever Acc wants to call them. I replied earlier to someone else's post that I found and fixed the error myself.
 
...they don't seem to be "reserved words" or whatever Acc wants to call them
Wow! With that kind of superior knowledge how could you possibly need our help?

They are Reserved Words and sooner or later not following DCrake's advice is going to cause your app to jump up and bite you in the ass, but you go right ahead and ignore the advice of the experts here!
 

Users who are viewing this thread

Back
Top Bottom