Can't Go to new record

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

Using the following in the On Action of a toolbar button

Public Function NewRecord()

Dim frm As Form

Set frm = Screen.ActiveForm
DoCmd.GoToRecord , , acNewRec

End Function

When I click the toolbar button nothing happens, no error
message nothing.

James
 
try the following, as

Public Function NewRecord()

On Error Resume Next

DoCmd.RunCommand acCmdRecordsGoToNew

End Function

use the following syntax to call the function from the OnAction property of
the toolbar button, as

=NewRecord()

hth
 
well, you've stumped me, just that quick. this is a bound form that you're
working with, correct? is the AllowAdditions property set to Yes?

hth
 
Bound form and AllowAdditions are set to Yes.
It works fine when I rub the code from a command button on
the form. My objective is to put all command buttons from my
form and place them in a toolbar. My form is cluttered with
command buttons!
It works when I use the New Record from the Insert menu
from the Access Built-In menu. I dragged and dropped it
onto my custom menu. I need now to set the focus to the
first field on the form. This is why I wanted my code to work.

Thanks,
James
 
I'm stumped also. I even set the focus to a field on the
form. The setfocus works but it refuses to go to a new record.

Public Function NewRecord()

Forms!frmAutoMtce!Description.SetFocus
DoCmd.GoToRecord , , acNewRec

End Function

Maybe I need to be a magician.
I don't believe in all my years using access have I had a problem
with something that seems so simple.
I can't even find anything in the Product Solution Center that can answer
this one.

James
 
Don't mean to keep replying to myself but I found the problem
I needed to reference the form in the GoToRecord:

DoCmd.GoToRecord acDataForm, "frmAutoMtce", acNewRec

James
 
good job! :)


JamesJ said:
Don't mean to keep replying to myself but I found the problem
I needed to reference the form in the GoToRecord:

DoCmd.GoToRecord acDataForm, "frmAutoMtce", acNewRec

James
 
Back
Top