Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Time Error 424 Object Required

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all!

I have a simple form in which there are two buttons next and previous. I have put this code under Form On current Event. A yellow line points and when I open the form it says "Run time error 424" Object required. Could you let me know what this is please?

Thanks.
 
I'm sorry, but what code have you put under the OnCurrent event? Could you please post it? Kathryn


 

Private Sub Form_Current()

If Me.NewRecord = True Then
cmd.PrevHistory.SetFocus
cmdNextHist.Enabled = False
Else

----> cmdNextHist.Enabled = True
End If

End Sub
 
OK, check out this modification:

Private Sub Form_Current()

If Me.NewRecord = True Then
Me!cmdPrevHistory.SetFocus // I removed a period after cmd
me!cmdNextHist.Enabled = False
Else
Me!cmdNextHist.Enabled = True
End If

End Sub

I think that might solve it.




Kathryn


 
I don't know why it is giving this..The code is correct.
It gives a different error this time.

Microsoft can't find the field CmdNextHist referred to in your expression.
The button names are perfect.




Private Sub Form_Current()

If Me.NewRecord = True Then
Me!cmdPrevHistory.SetFocus
Me!cmdNextHist.Enabled = False
Else
--> Me!cmdNextHist.Enabled = True
End If

End Sub
 
OK,not to doubt you, but one button is cmdPrevHistory and the other is cmdNextHist. Are you sure it's not cmdNextHistory?

If the name is correct, then you need to set a breakpoint in your code and then when you open your form you can see exactly what Access thinks your buttons names are.

In case you don't know how to do this, here's a quick lesson.

Put your cursor on the line with your If statement and press F9. This creates a breakpoint.

Run the form. The code window should open with the line on which you put the breakpoint highlighted.

Then type Ctrl-G. This will bring up the Command Window. In the top of the command window is a listing of all the current objects. One should be Me. This refers to the current form.

To the left of Me is a plus sign. click on it and you will see a listing. Navigate throught the tree until you get to the listing of the controls and find your buttons and check the name property.

This is very tedious, but sometimes it is necessary, so it is a good skill to know. Kathryn


 
I've gotten Error 424 myself. In my case, it was because I had security permissions established on the database, but I hadn't given permission to the particular group I was testing. I had to trap the error so it would tell me what I had forgotten (in this case, it was a query that ran the report). If you have Microsoft Security on your database, then you may have missed one of the permissions.

Linda Adams (Garridon@aol.com)
"The Importance of Being Grammarian," published in The Toastmaster, March 2001
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top