View Full Version : Auto-Fill Fields on Open


Sol
09-21-2000, 06:13 AM
From the navigator I'd like to open a form and auto-fill the created by & time fields. I've tryed using (in comments below) me.field name and formname.fieldname and both error out? Any suggestions...

Private Sub Command45_Click()
DoCmd.OpenForm "frmCustomer", , , , acFormAdd
'me.CreatedD_T.value = Now()
'frmCustomer.CreatedBy = CurrentUser()
End Sub

Thanks!

Travis
09-21-2000, 07:16 AM
Add this code to the Form_BeforeInsert Event of frmCustomer

if me.NewRecord then
me.CreatedD_T.value = Now()
me.CreatedBy = CurrentUser()
end if

This event fires only on the first entry in the record. Thus it will not effect previous records. Again this will place the values in the record only when you start data entry. This is a safe way to prevent have incomplete records in the data because someone went in and then left.

hope this helps