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

Log UserName after Update 1

Status
Not open for further replies.
Jun 2, 2004
66
0
0
US
I have a shared .mdb that is on a network server. On my form, I have a field called Problems (formatted as Memo)where users can enter data. This field is added onto quite a bit, as many users keep adding data underneath the prior entries (all in the same field box).

What I am trying to do is somehow capture their login after they type an entry into this Problems box. I would like their login to appear directly underneath their entry, so that I know who made the entry.

I have tried using the following on AfterUpdate, but it just completely clears the existing text and just logs the username.

Private Sub Problem_AfterUpdate()
Problem = fOSUserName()
End Sub

Is there a way for this to work so that it doesn't clear all of the existing text? As noted before, I would like the username to appear directly below the entry that that user makes. Any ideas?

 
This is a very difficult problem because you are trying to use the memo field as a rich text field.

A memo field is not really part of the table structure within Access. Rather, Access links to the memo from the table -- the memo is treated more like an object, not a text field. There are lots of restrictions to using a memo. For example, up until Access 2000, you could not even search within a Memo field. Now you can search the first 255 characters. (255 characters is the maximum text field entry).

So to insert text into the middle of a memo would not be easy.

How about trying a work-around. Have the end user enter the information into a text box. Add their name to the text, and then append the information to the memo.

You probably know about the environ function. Fox example,
strUser = environ("username")

Oh yea. Perhaps an even better approach is to use a history table. Each entry is a new memo field that includes date and time entered, username, plus the memo.

Richard
 

You can not concatenate memo fields. But you can save the contents of the memo field to a string variable. Then you can concatenate the name (or what have you) and place the result back into the memo field.

Here is a sample NOT complete...
Code:
Dim strOld As String 
Dim strAppend As String 

strOld = Me![memofield] 
' txtAppend is the control contains the string you want to append  
' to the memo field 
strAppend = Me!txtAppend 
'Insert your user id (trim in necessary) before or after
Me![memofield] = strOld & strAppend   'do forget to add user here.


[thumbsup2]



 
Thanks again lupins46. Now if I want that entry to be bold, how do I do it using FontBold = True?

I tried to add it to the code, but it bolds my entire memo field instead of just the username.

Thanks
 


You can NOT change fonts or attributes within a memo field.

Sorry...

 
I agree - you can't have different font styles within a memo field.
 
Sorry to bring this one to life again, but I'm having a problem with the code.

"Problem = problem & vbnewline & fosusername()" works the way I wanted it to, but it fills in the username regardless of whether or not the user makes an entry.

So even if a user selects the field and tabs out of it without entering anything, their name will be logged. I don't want this.

I only want their name to be logged if they make an entry. Any ideas?
 


If that does not work. Use my code example (above) and modify it too save the memo field before display and then compare the two strings.

Just a thought!

 
Have you moved the code from the Afterupdate event to a different event? It's the Afterupdate event that you want.
 
Looks like I had mistakenly placed the code under the Lost Focus event. That's why I was having problems. Now that it's back where I initially intended it to be, it works great. Thanks all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top