UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Setting Focus In Textbox After Selection From A List, Access 2010    
 
   
Machino
post Apr 21 2017, 12:29 PM
Post#1



Posts: 120
Joined: 31-August 07



Hi All
I have a combobox with a list of choice. One I select one of the choice, it places a prefix in a text box just below the combobox. That is all working well. Now, I would like to have the cursor automatically move to the end of the prefix in the textbox below. How can I do this? Thanks.
Manuel A. Ayala
Go to the top of the page
 
jwhite
post Apr 21 2017, 12:32 PM
Post#2


UtterAccess VIP
Posts: 5,777
Joined: 31-August 06
From: North Carolina, USA


I believe this will work: me!YourControlName.SelStart = me!YourControlName.SelLength

--------------------
Go to the top of the page
 
Machino
post Apr 21 2017, 12:44 PM
Post#3



Posts: 120
Joined: 31-August 07



Hi
To what event do I apply this code to? Thanks.
Manuel
Go to the top of the page
 
jwhite
post Apr 21 2017, 12:51 PM
Post#4


UtterAccess VIP
Posts: 5,777
Joined: 31-August 06
From: North Carolina, USA


I reckon right after you put the prefix in the textbox - up to you - your design.

--------------------
Go to the top of the page
 
Machino
post Apr 21 2017, 12:58 PM
Post#5



Posts: 120
Joined: 31-August 07



Hi
I added your to code to On Open event and it set the cursor to the correct location when I open the form. That is great. I then added it to the AfterUpdate event and I am getting the following error message. The code I am using is:
Me.CHANGEORDERNo.SelStart = Me.CHANGEORDERNo.SelLength

I am not sure how to correct for the error. Thanks.
Attached File(s)
Attached File  focus_error..JPG ( 18.82K )Number of downloads: 0
 
Go to the top of the page
 
jwhite
post Apr 21 2017, 01:01 PM
Post#6


UtterAccess VIP
Posts: 5,777
Joined: 31-August 06
From: North Carolina, USA


The answer is in the message - set focus to the control before executing that line of code: Me.YourControlName.SetFocus

--------------------
Go to the top of the page
 
Machino
post Apr 21 2017, 01:42 PM
Post#7



Posts: 120
Joined: 31-August 07



jwhite
Thank you very much. That worked beautifully. Take care.
Manuel
Go to the top of the page
 
jwhite
post Apr 21 2017, 01:52 PM
Post#8


UtterAccess VIP
Posts: 5,777
Joined: 31-August 06
From: North Carolina, USA


thumbup.gif

--------------------
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    30th April 2017 - 11:39 AM