Use UserID in subform as default

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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)
 
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)
 
Back
Top