Highlighting ActiveX Control's input when tabbing in

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got a CoyoteCalendar2.Calendar combo box on my form and I'd like it to
highlight whatever data is in it when the user tabs to it so that when the
user starts typing, the data is overwritten. I see a couple of potential
properties that could possibly make this happen. They are: On Updated, On
Enter, and On Got Focus. But I don't know the VB code for it. Has anyone
dealt with this before?
 
Aw, c'mon. Somebody's gotta have an idea of how to fix this. :(
--

Given that I've never used - or even heard of - CoyoteCalendar, I'm sorry, but
all I can suggest is that you contact whoever created that non-Access control.

John W. Vinson [MVP]
 
Ok, forget about the CoyoteCalendar part. I just want the data that's in
each text box or combo box to be selected when a user tabs into that field so
when they start typing, their input replaces what was previously there.
Right now, the cursor appears at the end of the data in each text box or
combo box when the user tabs to it. The last tab stop on my form is actually
a command button and when I tab again after that, it takes me to a new blank
form. I'd prefer if it went back to the first field on the current form.
Any suggestions?
--
Sue
Programmer/Data Analyst
Minnesota
 
I just want the data that's in
each text box or combo box to be selected when a user tabs into that field so
when they start typing, their input replaces what was previously there.

Quite a different question of course!

In the textbox's GotFocus event:

Private Sub controlname_GotFocus()
If Not IsNull(Me.controlname) Then
Me.controlname.SelStart = 1
Me.controlname.SelLen = Len(Me.controlname)
End If
End Sub


John W. Vinson [MVP]
 
Hi, John.

Sorry I didn't reply sooner. I was out of town all last week. I'm getting
a compile error on the last line of the if block. The ".controlname" is
highlighted in the Len function:

Me.controlname.SelLen = Len(Me.controlname)

The error message is Method or data member not found. If I comment this
line out, the rest of code compiles fine which is weird because
".controlname" is used 3 other times in the code and I don't get a compile
error on those. Suggestions?
--
Sue
Programmer/Data Analyst
Minnesota
 
Sorry I didn't reply sooner. I was out of town all last week. I'm getting
a compile error on the last line of the if block. The ".controlname" is
highlighted in the Len function:

Me.controlname.SelLen = Len(Me.controlname)

The error message is Method or data member not found. If I comment this
line out, the rest of code compiles fine which is weird because
".controlname" is used 3 other times in the code and I don't get a compile
error on those. Suggestions?
--

I cannot see your form; I did not know the name of the textbox on the Form
where you want this to happen. Therefore I posted sample code for you to adapt
to your own particular form.

Replace "controlname" with the actual name property of the textbox on the
form.

John W. Vinson [MVP]
 
I realize you used "controlname" for the name of my textbox. I replaced all
the controlnames in your code with my textbox's real name which is
Process_ID_Num_Text_Box. That's why I'm so stumped why your code gives me a
compile error.
 
I realize you used "controlname" for the name of my textbox.

good... but you didn't say so... said:
I replaced all
the controlnames in your code with my textbox's real name which is
Process_ID_Num_Text_Box. That's why I'm so stumped why your code gives me a
compile error.

Does the Name property in fact have the underscores, or does it have blanks?
Access will convert a name "Process ID Num Text Box" to
"Process_ID_Num_Text_Box_AfterUpdate()" when it generates code, but the value
you use in the code must match the actual name (surrounded by [brackets] if it
contains blanks or other special characters).

Perhaps you could copy and paste your actual code to a message if this doesn't
help.

John W. Vinson [MVP]
 
The name property for the text box actually has the underscores. Here is my
code:

Private Sub Process_ID_Num_Text_Box_GotFocus()

If Not IsNull(Me.Process_ID_Num_Text_Box) Then
Me.Process_ID_Num_Text_Box.SelStart = 1
Me.Process_ID_Num_Text_Box.SelLen = Len(Me.Process_ID_Num_Text_Box)
End If

End Sub
 
The name property for the text box actually has the underscores. Here is my
code:

Private Sub Process_ID_Num_Text_Box_GotFocus()

If Not IsNull(Me.Process_ID_Num_Text_Box) Then
Me.Process_ID_Num_Text_Box.SelStart = 1
Me.Process_ID_Num_Text_Box.SelLen = Len(Me.Process_ID_Num_Text_Box)
End If

End Sub

Apologies!!! Brainfade on my part.

It's SelLength, not SelLen.

John W. Vinson [MVP]
 
Back
Top