Use UserID in subform as default

G

Guest

I have a secured Access 2002 database and want to have a field in a subform
default to the current user ID. The subform has 3 field, date, commenter, and
comment. I have defaulted the date to date() in the properties but when I
tried to use CurrentUser() as the default in the property of the Commenter
box, it doen't work.

I want to default to work on only new records so the user doesn't have to
enter it manually.

Any suggestions ?

Thanks
 
D

Douglas J. Steele

You can either assign the value to the field in the form's BeforeInsert
event, or you can set the DefaultValue for the text box control in the
form's Load event.

To go the DefaultValue view, try something like:

Private Sub Form_Load()

Me.MyTextbox.DefaultValue = Chr$(34) & CurrentUser() & Chr$(34)

End Sub

(* "Form" above applies to the form being used as a subform, not to the
parent form)
 
G

Guest

Thanks for your help.

Douglas J. Steele said:
You can either assign the value to the field in the form's BeforeInsert
event, or you can set the DefaultValue for the text box control in the
form's Load event.

To go the DefaultValue view, try something like:

Private Sub Form_Load()

Me.MyTextbox.DefaultValue = Chr$(34) & CurrentUser() & Chr$(34)

End Sub

(* "Form" above applies to the form being used as a subform, not to the
parent form)
 

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