Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically add initials, date & time to a notes field

Status
Not open for further replies.

gbs01

MIS
Jun 2, 2003
73
US
I have a form with the following fields:
---------
- AcctNum
- txtAppendField
- btnAppend
- txtNotes
---------
Here's what I need to be able to do:

1) Have user type in comments/notes into the AppendField,
2) Then click the btnAppend button & have the text added to the top of the txtNotes.
3) Also need the user's initials,date & time added to the beginning of the txtAppendfield.

The appended text should look like this:
----------------------------------------
5/3/2005 4:52:36 PM - JAA: Chuck called to say circuit ok.
(auto info created) (this is the text typed in by user)

It also needs to be added to the top of any previously entered text in the txtNotes field.

I pull the username using Environ("username").

I'm just not sure how to do the append thing.

Thanks in advance for your help!
jlig
 
I think this is what you are trying to do:

Dim sNote as String

sNote = Now() & "-" & Environ("username") & ": "

IF IsNull(Me.txtAppendField)=TRUE or Me.txtAppendField = "" THEN
Msgbox "Please Enter A Note",vbInformation
ELSE
sNote = sNote & Me.txtAppendField
sNote = sNote & vbNewLine & Me.txtNotes
Me.txtNotes.Text=sNote
END IF
 
Thanks for the kind post.

I get run-time error 2185 : You can't reference a property or method for a control unless the control has the focus.

The debugger stops on : Me.txtNotes.Text = sNote

It seems like it doesn't like my txtNotes field?

thanks,
jlig
 
Replace this:
Me.txtNotes.Text=sNote
By this:
Me!txtNotes = sNote

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV, You are amazing!

To further fine tune this....

1) How do I make the username in all CAPS?

2) How do I make it add one blank line below the notes, or just add a cr/lf/enter at the end of the txtNotes?

This would keep the new text from running with the old.

Thanks again!
 
Me!txtNotes = Now & " - " & UCase(Environ("UserName")) & " : " & Me!txtAppendField & vbCrLf & Me!txtNotes

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That did the trick except adding the blank line between the new & the old.

I moved the vbCrLf around but no good.

jlig
 
blank line
Me!txtNotes = Now & " - " & UCase(Environ("UserName")) & " : " & Me!txtAppendField & vbCrLf & vbCrLf & Me!txtNotes

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Oh my Gosh, That did the trick!
Where do you guys get all of this information?
Books? Instructors?

Thanks again,
gbs01

 
Where do you guys get all of this information?
Simply by playing with F2 and F1 keys when in VBE.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
on the vbCrLf , how did you know to enter it twice? I checked out the F1 & F2, but it doesn't mention that.

Thanks for the help..
gbs01
 
vbCrLf just adds a Carriage Return and Line Feed at the end of the text string. The first one starts a new line. The second one starts ANOTHER new line immediately, hence the first one is blank.

Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
vbCrLf is the Visual Basic constant for a hard return (visual basic Carriage return Line feed) - you put in as many as you need; just as if you were typing in a text document, you would hit <Enter> for as many times as you want a new line. Corresponds to the combination of characters 13 and 10 in the ASCII character set.

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top