Auto initials & auto date not working right

G

GD

I have a subform (defaulted as continuous form) within a form that consists
of comment, user initials, and date fields. I need the user initials & date
fields to auto fill when an entry is made to the comment field. For those
comments that already exist, the user initials & dates need to remain as they
were at the time of their entry. My code in the subform is:

Private Sub txtComment_AfterUpdate()
If Me.txtComment <> "" Then
Me.txtCommentBy = CurrentUser()
Me.txtCommentDate = Date
Else
Me.txtCommentBy = ""
Me.txtCommentDate = ""
End If

End Sub

Private Sub Form_Current()
If Me.txtComment <> "" Then
Me.txtCommentBy = CurrentUser()
Me.txtCommentDate = Date
Else
Me.txtCommentBy = ""
Me.txtCommentDate = ""
End If

End Sub

Does the form need code, too?

Right now, for every form I open the user initials & dates change to my user
initials and today's date. Have I explained it adequately?

THANKS!!!
 
L

Linq Adams via AccessMonster.com

Right now, for every form I open the user initials & dates change to my user
initials and today's date. Have I explained it adequately?

That's because of the repeated code in the Form_Current event! It's not
needed and will change the user name and date every time the record is
accessed, even if it's not changed. Simply delete the Form_Current() sub.
 

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