textbox setfocus and select current contents
How can I get it to have the RunDate textbox take focus the SAME WAY it
does
when it takes focus by TABBING INTO the RunDate textbox?
You might run this code when the text box is selected:
Private Sub TextBox1_Enter()
With TextBox1
.SelStart = 0
.SelLength = 500 ''anything = to len of text
End With
End Sub
--
Jim
"rcmodelr" wrote in message
...
I have a VBA application for Excel I use to check load counts from farms in
the plant's run schedule.
The Userform has one multipage form where page 1 gets the Run Date, Farm
Name & Number, then 8 textboxes each, for House Number, Birds/house, Crew
catching the house, Bird Weight, and total weight coming out of the house.
At the bottom of the userform, it shows the projected load net weight,
load
count, & number of cages to expect on the last load at the selected catch
count.
Page 2 of the MultiPage breaks down the bird count, load & last load cage
count by crew.
I have it so when the OK button is clicked, it will place the data into a
worksheet, then select page 1 of the multipage, and setfocus on the run
date.
( RunDate.Setfocus )
BUT... if the user TABS into the RunDate or any other TextBox, the system
will AUTOMATICALLY select ALL the textboxes current contents so if I type
a
letter, it will replace EVERYTHING in the textbox with what I type.
I WANT this to happen when page1 is already shown and the RunDate takes
focus. But using RunDate.Setfocus ONLY places the cursor INTO the RunDate
Textbox where it was last time I tabbed out of the RunDate textbox.
How can I get it to have the RunDate textbox take focus the SAME WAY it
does
when it takes focus by TABBING INTO the RunDate textbox? I've tried every
way I could think of including trying ALL the RunDate textbox properties
set
in literally EVERY available setting, but no matter HOW the textbox
settings
are configured, when the textbox takes focus with the .Setfocus, it will
ONLY
place the cursor into the textbox where it was last time, and trying to
use
other properties such as .copy won't accomplish this either.
Only way I've found that SOMETIMES (but NOT ALWAYS) works is if I have
Page2
showing when I click OK. But even then, ONE time, it will work and
setfocus
to the RunDate box on page1 with the RunDate contents highlighted for
overtyping, next 3 or 4 times, it will be JUST LIKE other attempts, just
placing the cursor IN the RunDate textbox but in a way where if I start
typing it just ADDS what I type to what is already in the RunDate textbox.
|