Determining when user adds new records

  • Thread starter Thread starter PosseJohn
  • Start date Start date
P

PosseJohn

I have a form that allows adding new records.

I want to set a few controls to particular values (based on user ID and
location) when the new record is first displayed.

Can I trap the new record addition anywhere?
 
I don't think you can trap it per se. but you can set a timestamp when the
new record is created, and by whom.

Use the Current event:

Sub Form_Current()
If Me.NewRecord = True Then
Me.txtTimeStamp = Now
Me.txtUser = fOSUserName()
End If
End Sub

The fOSUserName function is here:

http://www.mvps.org/access/api/api0008.htm
 
I have a form that allows adding new records.

I want to set a few controls to particular values (based on user ID and
location) when the new record is first displayed.

Can I trap the new record addition anywhere?

Try using the form's Current event:

Private Sub Form_Current()
If Me.NewRecord Then
' you're on a new record the moment that it was created
End If
End Sub

The form's BeforeInsert event might be appropriate as well.
 
Back
Top