Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2006
    Posts
    2

    Selecting text - ComboBox

    Please can somebody help me to select all text in a combobox during the on_click or on_enter events. I can do it for a textBox but not a combobox.



    Please help, the textbox code I am using is as follows:

    Private Sub txtStart4_Click()
    With Me.ActiveControl
    .SelStart = 0
    .SelLength = Len(Me.ActiveControl.Text)
    End With
    End Sub

    Thanks,
    B.

  2. #2
    Join Date
    Jun 2006
    Location
    USA
    Posts
    6
    Hello:

    If you had a form with a combo box on it name cboMonths and a command button named cmdSelect, The below code works:

    Private Sub cmdSelect_Click()
    cboMonths.SetFocus
    cboMonths.SelStart = 0
    cboMonths.SelLength = Len(cboMonths.Text)
    End Sub

    If your using the ActiveControl method, you may need to set focus to the control

    Regards
    Mark

  3. #3
    Join Date
    Mar 2006
    Posts
    2
    Thnaks for your reply Mark,

    The trick is to select the text during the on_enter event of the textbox. In other words, once the user clicks on the textbox, any previous text will be highlighted (selected) for immediate replacement.

    Cheers,

    B.

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

Similar Threads

  1. Problem Selecting Records for a Report
    By Joe in forum Programming
    Replies: 0
    Last Post: 09-27-2008, 02:27 PM
  2. query based on two combobox
    By datto in forum Queries
    Replies: 0
    Last Post: 04-18-2007, 11:10 PM
  3. Replies: 1
    Last Post: 11-11-2006, 08:23 PM
  4. Replies: 1
    Last Post: 03-17-2006, 12:04 PM
  5. Combobox synchronization in a subform
    By pe_z in forum Forms
    Replies: 0
    Last Post: 02-26-2006, 01:48 PM

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