HELP! Object defined error?

D

Dave

Hi,

I am attempting to add a new record to a subform by pressing a command
button. So when I press the command button I would like the cursor to jump to
a new record. However, I cannot figure out how to achieve this through code
behind the command button. I know it is possible as I can press the Access
'New Record' menu option and it will do exactly as I would like. Whatever I
seem to try, I am constantly getting an 'Object defined error' message.

Thanks in advance,
Dave
 
F

Frits van Soldt

Dave said:
Hi,

I am attempting to add a new record to a subform by pressing a command
button. So when I press the command button I would like the cursor to jump to
a new record. However, I cannot figure out how to achieve this through code
behind the command button. I know it is possible as I can press the Access
'New Record' menu option and it will do exactly as I would like. Whatever I
seem to try, I am constantly getting an 'Object defined error' message.

Thanks in advance,
Dave

Try this:
runcommand acCmdRecordsGoToNew
 
V

Van T. Dinh

If the CommandButton is in the Subfor, you can use something like:

Private Sub Command6_Click()
DoCmd.GoToRecord , , acNewRec
End Sub

If the CommandButton is in the main Form, you need to set the Focus to the
SubformControl first before the GoToRecord.
 
Top