Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Apr 2002
    Location
    St. Paul, Minnesota, USA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting cursor to end of text (Access 2000)

    Hello all,

    I have an access form with a large textbox (Reason_for_Change) on it so that when a user clicks on it their username (captured at login) and the current data/time appears, appended to whatever is already in the text box. That much of the code I have figured out:

    Reason_for_Change.Value = Reason_for_Change.Value & vbCrLf & vbCrLf & gstrUserID & " " & Now

    But my problem is that it leaves the textbox (Reason_for_Change) with all of its text highlighted. I want it to add the login information and time to the end of the text that is already in the textbox and leave the cursor either at the end of the text or, even better, on the next line (without all the text in the textbox highlighted).

    Any ideas?

    Thanks in advance,

    Amanda

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting cursor to end of text (Access 2000)

    Go to tools/options/keyboard tab. You can set the enter field behavior to go to end of field. This is a global setting so I'm not sure if this suits your needs. The only other thing I can think of is to use a <shudder> Sendkeys statement to pas an <F2> to the control. I tend to shy away from Sendkeys if I can. Pass a <CTRL + ENTER> to go to the next line.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Setting cursor to end of text (Access 2000)

    Change your line to this:

    Reason_for_Change.Value = Reason_for_Change.Value & vbCrLf & vbCrLf & gstrUserID & " " & Now & vbCrLf

    Then add this line next:

    Me.Reason_for_change.SelStart = Me.Reason_for_change.SelLength + 1
    Charlotte

  4. #4
    Lounger
    Join Date
    Apr 2002
    Location
    St. Paul, Minnesota, USA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting cursor to end of text (Access 2000)

    Worked like a charm! Thanks so much!!

    Regards,

    Amanda

  5. #5
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Setting cursor to end of text (Access 2000)

    Just some food for thought. Your design will create a memo field (presumably) that grows each time you change the record. In addition, the usual requirement is to see why the last change was made, so you have to go to the end of the field in your text box to see that, and then read backwards if you want to see what the previous reason was. We do it a bit differently, and write out a record each time a change is made so we have a change history. In doing it that way, we can force people to put in a text string of reasonable length, and can usually limit the data to a text field of 255 characters. Then we we display it we sort it in descending date order (the record contains a DateTime field and an ID field that form a primary key) so the user can read the info in a more friendly manner. I realize you may be committed to your approach, but the concepts might be useful next time around.
    Wendell

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Setting cursor to end of text (Access 2000)

    Wendell is correct in taht his approach is much more structured and far easier to maintain.

    However, if you were to rearrange your statement:
    Reason_for_Change.Value = Reason_for_Change.Value & vbCrLf & vbCrLf & gstrUserID & " " & Now & vbCrLf

    to:
    Reason_for_Change.Value = vbCrLf & vbCrLf & gstrUserID & " " & Now & vbCrLf & Reason_for_Change.Value

    You would then get your latest Reason at the top of your memo field.
    Just my 2 bobs worth.
    HTH
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

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