What event is fired when one uses the Access add new record selector?

J

JJ_377

What event is fired when one uses the Access add new record selector? I
need to put code in that event. I would like the resulting blank form
to autopopulate with information.
Thank you?
 
D

Dirk Goldgar

What event is fired when one uses the Access add new record selector?
I need to put code in that event. I would like the resulting blank
form to autopopulate with information.

There's no special event for that, but you can check in the Current
event to see if the record that just became current is the new record:

Private Sub Form_Current()

If Me.NewRecord Then
' ... do something ...
End If

End Sub
 
J

Jules

Thank you but I'm getting nothing from form current, which I tried to
get into before making this posting. There is existing code in this
event and I replaced it with your test code, just to see if I can get
into that event and...nothing:

Private Sub Form_Current()

If Me.NewRecord Then
MsgBox "IN FORM CURRENT"
End If

'some existing code
'some more code
'even more code...
'blah blah blah
'yada yada yada


End Sub

?
Thanks again!
 
D

Dirk Goldgar

Jules said:
Thank you but I'm getting nothing from form current, which I tried to
get into before making this posting. There is existing code in this
event and I replaced it with your test code, just to see if I can get
into that event and...nothing:

Private Sub Form_Current()

If Me.NewRecord Then
MsgBox "IN FORM CURRENT"
End If

'some existing code
'some more code
'even more code...
'blah blah blah
'yada yada yada


End Sub

?
Thanks again!

I can't imagine why that wouldn't work, so long as you have the form's
OnCurrent property set to "[Event Procedure]". It certainly works for
me.
 
G

George Nicholson

Just a guess:
-With the form in design view and the properties window showing:
1) look at the OnCurrent property and make sure it is set to
[EventProcedure].
2) Double check that clicking on the ellipse (...) by the OnCurrent
property takes you to the code you have entered.

Once properly set, the message box in your code should appear *when you move
to a new record*.

HTH,
 
J

Jules

Dirk - you are right - I missed the property page assignment of the on
current event. I assumed that becase there was legacy code in the code
page, this assignment had been made...wonder why this wasn't notice
before...
thanks again!
 
J

Jules

I can't imagine it either..there has to be some setting somewhere I'm
missing...
Thank you.
Jules
 
D

Dirk Goldgar

Jules said:
I can't imagine it either..there has to be some setting somewhere I'm
missing...

Are you saying it still isn't working? Put an unconditional message box
in the Current event, to see if the procedure is being called at all.
If not, do a Debug -> Compile and see if there are any compiler errors
that could be keeping the code from being compiled and executed.
 
Top