Results 1 to 6 of 6

Thread: Memo Field

  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Good morning...

    I have a memo field on a form. If you scroll down in the form to read the text and then that memo field loses focus...the memo field resets back to the top of the text.

    My question is...is there a way to "freeze" the memo field in its current position when it loses focus?

    Thanks!

    Steve

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You can do this using a bit of code. Let's say the text box bound to the memo field is named memNotes.

    Place the following declarations at the top of the form's code module, below Option Compare Database and Option Explicit but before all Subs and Functions:

    Private lngStart As Long
    Private lngLength As Long

    Create the following event procedures (substituting the correct name of course):

    Code:
    Private Sub memNotes_GotFocus()
      If lngStart > 0 Then
    	Me.memNotes.SelStart = lngStart
      End If
      If lngLength > 0 Then
    	Me.memNotes.SelLength = lngLength
      End If
    End Sub
    
    Private Sub memNotes_LostFocus()
      lngStart = Me.memNotes.SelStart
      lngLength = Me.memNotes.SelLength
    End Sub
    (It's not perfect, though)

  3. #3
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'll give it a shot...thanks!

  4. #4
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It does not work as expected.

    When the memo field loses focus...it still returns to the top of the field. Although when the memo field gets focus again...it does return to the spot where the cursor last was.

    Any other ideas?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    There is no way to prevent that behavior, as far as I know, so this is the best you can do. The code that I posted only lets the user return to the same place in the text box.

  6. #6
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your time.

    If I ever figure it out...I'll be sure to share.

    Have a great day!

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •