Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to : select the whole text of a combo on click

Status
Not open for further replies.

tektipdjango

IS-IT--Management
Jan 28, 2004
188
when you click in a comboBox the text is not selected even if in the
event onClick you write the following code which works with a textBox:
(cBox is the name of the comboBox)
cBox.SelStart = 0
cBox.SelLength = Len(cBox.Text)

It looks like Access is sending an event after the onclick for the
cursor to go inside the text of the comboBox.

To succeed you have to put the code in the mouseUp event.
But this prevents you to select a part of the text the usual way.

To achieve this, declare a variable in the form module :
---------------
dim arrivalInCBox as Boolean

sub cBox_Enter()
arrivalInCBox =true
end sub

sub cBox_MouseUp()
if arrivalInCBox =True then
cBox.SelStart = 0
cBox.SelLength = Len(cBox.Text)
arrivalInCBox =False
end if
end sub
---------------
 
You need to use the selected and column properties of a combo box. The help in access for these properties give you examples which will show you.
In affect you get the selected `row` number, then ask it to give you the data in the columns when the row is the number you got from the selected property. NB column numbers start with 0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top