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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date\time inserted into text box 2

Status
Not open for further replies.

famehrie

ISP
Dec 14, 2002
31
US
I have a form with a text box which is used to store notes and comments about the work done on a particular issue. The data is linked to a field in a table. What I want to do is have the date, time and a persons username inserted automatically at the beginning of the new entry in this text field without erasing the previous data. I already have the code to grab the windows username and I know how to automatically display the date and time. Below is an example of what I want to happen. I was going to set this to occour in the OnFocus event.

Work Comments
Username 4/10/04 4:30 PM <-------Auto filled in
Sub called requesting a technician be sent to location.
Will check with dispatch to inquire about send one.

Username 4/10/04 5:30 PM <----Also auto filled in old data still visible
Tech will be sent on thursday.
 
Try this code as an example:
Code:
If Me![WorkerComments] = " " Or Me![WorkerComments] = "" Or IsNull(Me![WorkerComments]) Then
    Me![WorkerComments] = CurrentUser & "-(" & Format(Date, "Short Date") & " " & Format(Time(), "Medium Time") & "):"
End If
Me![WorkerComments].SelLength = 0
Me![WorkerComments].SelStart = Len(Me![WorkerComments]) + 1

Put the above code in the Got Focus event procedure of the control WorkerComments. This will also place the cursor behind this entry ready for the user to start typing in the comments.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
scriverb,

Thanks for the code from before. Although It did not prove to be exactly what I was looking for it set me on the right path. I was not familiar with the SelLenght and SelStart stuff. Ad because you mentioned it I was able to find what I needed.

One star to you.
 
Thanks for the star and glad to give you the push.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top