By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,844 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,844 IT Pros & Developers. It's quick & easy.

placing text insertion point at the end of combobox contents

P: 2
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_AfterUpdate event procedure.
Me.cboEmpID.SelStart = Len(Nz(Me.cboEmpID, ""))
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.SelLength = 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.SetFocus
cboEmpID.SetFocus
Once again, this is aesthetic; the form runs perfectly otherwise.
Jan 3 '12 #1

✓ answered by yptrumpet

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.

Share this Question
Share on Google+
1 Reply


P: 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.
Jan 3 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.