Determining when user adds new records

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?
 
A

Arvin Meyer [MVP]

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
 
J

John W. Vinson

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.
 

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