The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Text Cursor focus in Memo field
Posted: 03 Apr 08 3:34 PM
|
I've added the following code to a memo field to add a time stamp to the memo when someone clicks the field:
Sub Memo1Click(Sender) Memo1.Text = Memo1.Text & vbcrlf & Now() & ": " End Sub
The problem is that the cursor goes to the top of the memo field instead of the end. How do I move the focus to the end of the text so new entries are entered correctly?
I'm sure the is simple and I'm missing something obvious. |
|
|
|
Re: Text Cursor focus in Memo field
Posted: 04 Apr 08 10:05 AM
|
I once worked with a memo field with a Timestamp button nearby that added the timestamp and set the focus. I seem to recall that then done that way (focus is set after the timestamp it added) the curser moved to the end of the text that was added. |
|
|
|
Re: Text Cursor focus in Memo field
Posted: 08 Apr 08 12:28 PM
|
Dan,
I ended up doing something similar. I created a second memo field for entering the note and then having a button to the right that would "Add Note" to the primary memo field with all the desired stamps and it worked great. An additional benefit is that you can make the primary memo field read-only, which in our case was a desired effect. |
|
|
|
Re: Text Cursor focus in Memo field
Posted: 07 Oct 08 6:24 PM
|
Well, I'm back around doing this again, but in 7.5 LAN rather than legacy, and I'm having the issues you reported:
The cursor goes to the beginning of the field rather than the end.
When I add the New test to the existing memo tect, I want a line feed, but any way I try to do that..
strNewNext & VBLF & strOldText or strNewText & Chr(10) & strOldText
.. just puts a | in between the new & old text.
Did you find a way around that? |
|
|
| |
|
Re: Text Cursor focus in Memo field
Posted: 08 Oct 08 7:40 AM
|
As I mentioned I created two memo fields and a button on my form. The main memo field (Memo1) is read only. The other memo field (mmoEnterNotes) is where the user can enter the note. The button (btnAddNote) adds the text from mmoEnterNotes into the Memo1 field with some other info that I wanted to collect (like the users name).
Here is the code for the onClick event: ------------------------------------------------------ Sub btnAddNoteClick(Sender) if mmoEnterNotes.Text = "" then exit sub else GetUsername 'Collects the name of the current user and stores it in the strName var. Memo1.Text = Memo1.Text & vbcrlf & Now() & " - " & strName & ": " & mmoEnterNotes.Text mmoEnterNotes.Text = "" end if End Sub ------------------------------------------------------
Nice and simple. We didn't want the users to modify or mess with anyone elses notes, thus the read-only setting on Memo1. |
|
|
|
Re: Text Cursor focus in Memo field
Posted: 08 Oct 08 9:41 AM
|
Another advantage of the two-field approach is when two users are looking at the record at the same time. This client's complaint was when two users added to the memo field at the same time, the second user to save would overwrite the first user's changes. My approach is not to combine the text of the two memo controls, but instead the save button reads the old text from the database, adds it to the new test field and then writes it back to the DB (and refreshes the large memo control). |
|
|
|