Results 1 to 5 of 5
  1. #1
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80

    Need search form to remove or select text after enter.


    So I have a search form that works properly as far as searching goes, but when you enter something to search for and hit enter it will search for that and return results but then the cursor moves to the beginning of the text box you enter the value to search for in. What this leads to is if you immediately type in a new value it puts it to the beginning. So if you searched for 'Jones' then hit enter and start typing something else it will be 'xyzJones'. Is there a way to make it clear what is entered in to the text box or at least select the text after searching so it will overwrite?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    That's an Access option.
    File->Options->Client Settings->Behavior Entering Field

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    That's not a setting for a given database, but for all databases run on the given machine...you'd have to do that on every machine running the database...and some users might object!

    To empty out the search box, each time you go to use it:

    Code:
    Private Sub YourTextBoxName_Click()
       Me.YourTextBoxName = Null
    End Sub
    
    Private Sub YourTextBoxName_GotFocus()
       Me.YourTextBoxName = Null
    End Sub

    To highlite the current data, on entering the Control:

    Code:
    Private Sub YourTextBoxName_Click()
     If Nz(Me.YourTextBoxName, "") <> "" Then
       Me.YourTextBoxName.SelStart = 0
       Me.YourTextBoxName.SelLength = Len(Me.YourTextBoxName)
     End If
    End Sub
    
    Private Sub YourTextBoxName_GotFocus()
     If Nz(Me.YourTextBoxName, "") <> "" Then
       Me.YourTextBoxName.SelStart = 0
       Me.YourTextBoxName.SelLength = Len(Me.YourTextBoxName)
     End If
    End Sub

    Linq ;0)>

  4. #4
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80
    Thanks MissingLinq, I am able to use yours for clearing the text field and it does work. I would prefer the selection method but when I use this it is still putting cursor at the start of the text box without selecting. I wonder if this is due to the fact I have the code on the 'After Update' event field?

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Ekhart View Post
    or at least select the text after searching so it will overwrite
    The second code example should do just this...regardless of where the cursor is, when the user starts to type the hilighted text will 'disappear,' replaced by the newly typed data.

    Linq ;0)>

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Remove enter parameters value pop up box
    By Triscia in forum Programming
    Replies: 3
    Last Post: 10-03-2013, 04:09 PM
  2. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  3. Replies: 12
    Last Post: 03-03-2013, 07:13 PM
  4. Replies: 4
    Last Post: 08-16-2011, 05:54 PM
  5. Replies: 0
    Last Post: 10-12-2010, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums