error 424 Object required

T

TimH

when I run this code in Access vba97 there is no error; However when i run
the exact same cose in ACCESS2000 I get the run-time error of object
Required (424); does any one have an Idea as to what is wrong?
Private Sub Form_Current()

Dim recClone As Recordset
Dim intNewRecord As Integer

Set recClone = Me.RecordsetClone

intNewRecord = IsNull(Me.PersonID)

If intNewRecord Then
cmdFirst.Enabled = True
cmdNext.Enabled = False
cmdPrev.Enabled = True
cmdLast.Enabled = True
cmdNew.Enabled = False
Exit Sub
End If

cmdNew.Enabled = True 'this is where the error occurs.
If recClone.RecordCount = 0 Then
cmdFirst.Enabled = False
cmdNext.Enabled = False
cmdPrev.Enabled = False
cmdLast.Enabled = False

Else
recClone.Bookmark = Me.Bookmark

recClone.MovePrevious
cmdFirst.Enabled = Not (recClone.BOF)
cmdPrev.Enabled = Not (recClone.BOF)
recClone.MoveNext


recClone.MoveNext
cmdLast.Enabled = Not (recClone.BOF)
cmdNext.Enabled = Not (recClone.BOF)
recClone.MovePrevious
End If
recClone.Close

End Sub
 
J

John W. Vinson

when I run this code in Access vba97 there is no error; However when i run
the exact same cose in ACCESS2000 I get the run-time error of object
Required (424); does any one have an Idea as to what is wrong?
Private Sub Form_Current()

Dim recClone As Recordset
Dim intNewRecord As Integer

Set recClone = Me.RecordsetClone

intNewRecord = IsNull(Me.PersonID)

If intNewRecord Then
cmdFirst.Enabled = True
cmdNext.Enabled = False
cmdPrev.Enabled = True
cmdLast.Enabled = True
cmdNew.Enabled = False
Exit Sub
End If

cmdNew.Enabled = True 'this is where the error occurs.

Try changing it to

Me!cmdNew.Enabled = True
 
T

TimH

Thank you however it did not work:
error 2465; the field "cmdNew" can't be found by MSOAccess

at the same line when I changed from
cmdNew.Enabled = True to
Me!cmdNew.Enabled = True
 
J

John W. Vinson

Thank you however it did not work:
error 2465; the field "cmdNew" can't be found by MSOAccess

at the same line when I changed from
cmdNew.Enabled = True to
Me!cmdNew.Enabled = True
--

Is there in fact a control (a command button??) named cmdNew on the form?
 
T

TimH

Thank you for your healp

yes there is a cmdNew button and the error was overcome by moving the code
line below the fallowing [If ] line however it generated an
error 424 beloww on the
Else
recClone.Bookmark = Me.Bookmark

recClone.MovePrevious
cmdFirst.Enabled = Not (recClone.BOF) 'error 424
cmdPrev.Enabled = Not (recClone.BOF)
recClone.MoveNext


recClone.MoveNext
cmdLast.Enabled = Not (recClone.BOF)
cmdNext.Enabled = Not (recClone.BOF)
recClone.MovePrevious
End If
recClone.Close

End Sub
 
T

TimH

John
again thank you

becaouse of your question on "Is there a cmdNew button?"
I reviewed my code against my cmdButtons and found my Error:

" cmdButtonRecord"

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top