Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have Userform1 containing several textboxes. When I first open the Excel file and open the Userform for the first time, the cursor correctly appears in the first textbox (Textbox1). However, if I exit the Userform and then go back in, the cursor appears in another Textbox instead of Textbox1. In fact, each time I exit the Userform and go back in, the cursor is in a different Textbox. (The TabIndex of Textbox1 is set to 0.
I've seen answers to several posts here giving a solution of Userform1.Textbox1.SetFocus. I've put that line in the Private Sub UserForm_Initialize() code, but it has not affect What code can I use so that whenever I open (show) Userform1, the cursor is always in Textbox1, and where do I place such code Many thanks Pau |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul,
It might be because the userform is being hidden, and so when it is next shown, the Initialize event is to used, that is for when it is loaded into memory. Throw your code into the Userform_Activate() event code, and see if that fixes it. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Paul Simon" wrote in message ... I have Userform1 containing several textboxes. When I first open the Excel file and open the Userform for the first time, the cursor correctly appears in the first textbox (Textbox1). However, if I exit the Userform and then go back in, the cursor appears in another Textbox instead of Textbox1. In fact, each time I exit the Userform and go back in, the cursor is in a different Textbox. (The TabIndex of Textbox1 is set to 0.) I've seen answers to several posts here giving a solution of Userform1.Textbox1.SetFocus. I've put that line in the Private Sub UserForm_Initialize() code, but it has not affect. What code can I use so that whenever I open (show) Userform1, the cursor is always in Textbox1, and where do I place such code. Many thanks, Paul |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks very much Bob. Your first paragraph was the clue to my problem. I changed from Hide to Unload Me, and now it works perfectly. Thanks again, Bob - I appreciate it
Pau ----- Bob Phillips wrote: ---- Paul It might be because the userform is being hidden, and so when it is nex shown, the Initialize event is to used, that is for when it is loaded int memory Throw your code into the Userform_Activate() event code, and see if tha fixes it -- HT Bob Phillip ... looking out across Poole Harbour to the Purbeck (remove nothere from the email address if mailing direct "Paul Simon" wrote in messag .. I have Userform1 containing several textboxes. When I first open th Excel file and open the Userform for the first time, the cursor correctl appears in the first textbox (Textbox1). However, if I exit the Userfor and then go back in, the cursor appears in another Textbox instead o Textbox1. In fact, each time I exit the Userform and go back in, the curso is in a different Textbox. (The TabIndex of Textbox1 is set to 0. I've seen answers to several posts here giving a solution o Userform1.Textbox1.SetFocus. I've put that line in the Private Su UserForm_Initialize() code, but it has not affect What code can I use so that whenever I open (show) Userform1, the curso is always in Textbox1, and where do I place such code Many thanks Pau |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul,
Could I advise you to re-consider. Sometimes, often, it is better to hide a sheet rather than unload it, thereby removing that load overhead if you re-load in the same session. You can still achieve your objective using the Activate event. Not saying you should, just make sure you are happy which is the best way for you. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Paul Simon" wrote in message ... Thanks very much Bob. Your first paragraph was the clue to my problem. I changed from Hide to Unload Me, and now it works perfectly. Thanks again, Bob - I appreciate it. Paul |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob,
You are absolutely right! If I load and unload the form several times, I eventually run out of memory. In fact, I even reached a point where Excel told me it could not save the file. (And exiting Excel does not regain the memory. You actually have to reboot.) Thanks very much for great advice, Bob. Paul ----- Bob Phillips wrote: ----- Paul, Could I advise you to re-consider. Sometimes, often, it is better to hide a sheet rather than unload it, thereby removing that load overhead if you re-load in the same session. You can still achieve your objective using the Activate event. Not saying you should, just make sure you are happy which is the best way for you. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Paul Simon" wrote in message ... Thanks very much Bob. Your first paragraph was the clue to my problem. I changed from Hide to Unload Me, and now it works perfectly. Thanks again, Bob - I appreciate it. Paul |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel VB - show userform1 (at same time) minimized application win | Excel Discussion (Misc queries) | |||
UserForm1.Textbox1.SetFocus Question | Excel Programming | |||
TextBox SetFocus Problem | Excel Programming | |||
UserForm TextBox to ActiveSheet TextBox over 256 characters | Excel Programming | |||
TextBox.SetFocus | Excel Programming |