placing text insertion point at the end of combobox contents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yptrumpet
    New Member
    • Jan 2012
    • 2

    placing text insertion point at the end of combobox contents

    Hi all. This is a bit of an aesthetic problem.

    I have a form containing two subforms and two comboboxes. When the forms first load, the first combobox receives focus. I'd like the text input cursor to be placed at the end of the text whenever the bombobox receives focus. Trolling Bytes.com tells me that the following code works for most people, so I put it in the cboEmpID_AfterU pdate event procedure.
    Me.cboEmpID.Sel Start = Len(Nz(Me.cboEm pID, ""))

    It doesn't work for me, for whatever reason. The combobox receives focus and selects all its text, as usual. I also unsuccessfully tried adding the following, but to no effect:
    Me.cboEmpID.Sel Length = 0

    Perhaps this has to do with some SetFocus shenanigans that runs right before, but I'm not sure. This is in place so that the datasheets in the subforms don't have their first cells selected. Here's the code:
    subfrm_Emp.SetF ocus
    cboEmpID.SetFoc us

    Once again, this is aesthetic; the form runs perfectly otherwise.
  • yptrumpet
    New Member
    • Jan 2012
    • 2

    #2
    Seems I figured out the problem. I made it so that the above-mentioned line of code runs in the combobox's Enter and Change event procedures. Putting it in the AfterUpdate procedure didn't do anything that I could see. Enter() takes care of when the control first receives focus, and Change() takes care of when a new value from the combobox options is selected.

    Well. Throw your head against a wall enough times and you just might get through. I'm also happy to report minimal brain damage from this frustrating experience.

    Mods, please mark this as "answered." I can't do it.
    Last edited by yptrumpet; Jan 3 '12, 05:17 AM. Reason: Can't mark this question "answered."

    Comment

    Working...