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!

placing the 'cursor' at the end of autoentry in a control

Status
Not open for further replies.

ray436

Technical User
Apr 11, 2000
254
0
0
CA
I have a field that automatically has the time and user name entered into it when the user makes an entry in this field ( its a memo field, so the time and user stamp keeps the memos from being a long stream of data with no "when was this added?" )

I am doing this:

-onGetfocus

[new_memo] = vbCrLf & vbCrLf & Now() & vbCrLf & CurrentUser() & vbCrLf

-onLostFocus

[notes]= [notes] & " " & [new_memo]
[new_memo] = " "

problem is that the time and user is placed OK, but the 'cursor' is above this info. I would like the place where the info gets typed to be after the time and user, without the person having to scroll down below it each time.

is this a use for selstart? would I just make the position in selstart some number bigger than I expect the time and use to be?

thanks for any ideas.
 
Dear Ray

Yes - it's a case for SelStart. I can't lay my hands on the details at the moment, but I needed to do this some time ago and that was the solution. All other fiddling about, including SendKeys "{END}" etc., didn't work for some reason.

If I can find 'chapter and verse' I'll post again.

Good luck.

Paul
 
This may be off course from you were planning but you could easily add one field to your table that holds your memo data. Make this field called DateEntered (or something like that) and in it's properties declare that it's Default Value is "=Now()". This way everytime you add a new record (or new memo), it will automatically insert the time and date into this second field and save it with the memo. Thought I would share this with you since adding a time stamp to the beginning of a memo field seems like your going about this the hardest way possible.
 
thanks people, yes Sameal, thats like what I am doing pretty much now. I have a locked field that shows the notes, including all additions so far, and a field directly above it that the user adds new memos into. when they leave this field, the entry they just made is added to the memo feild below with the time and user who made the entry. problem is tho, the time and user info appears below what they have typed unless they scroll down in the field before they type. PaulMilnes: ya I can't find a good example that matches what I want either. I think it is something like selstart(20) to place the entry point 20 charachters in, but I can't get it to implement correctly.
 
and the winner is......

on get focus:

If [new_memo] <> &quot;&quot; Then
Text1 = vbCrLf & vbCrLf & Now() & CurrentUser() & vbCrLf & &quot;me&quot; & vbCrLf
End If
[new_memo].SelLength = 1
[new_memo].SelStart = Len([new_memo].Text) + 1

on lost focus:

[Notes] = [Notes] & &quot; &quot; & vbCrLf & &quot;- - - - - - - - - - - - - - - - - - - - - - - -&quot; & vbCrLf & CurrentUser() & vbCrLf & Now() & vbCrLf & vbCrLf & [new_memo]
[new_memo] = &quot;&quot;


Im sure it could be cleaned up, but hey it works!!!

the dashes are to visualy separate entries, it made it a little easier to scroll thru looking for the start of entries. not sure why the first Now() and Currentuser() didn't work ... oh well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top