Setting text of a control box in VB

  • Thread starter Thread starter mrs
  • Start date Start date
M

mrs

Not sure if this is the correct forum...

How do you set the text in a combo box, that is in the
list already, using VB?

Thanks

Matt
 
mrs said:
Not sure if this is the correct forum...

Close enough ;-)

How do you set the text in a combo box, that is in the
list already, using VB?


Several ways to do this. Easiest is to set the combo box's
value to the desired bound column value. Another is to set
the combo's Text property to the string in the first visible
column. Finally, you can set the combo's Index property to
the desired row number.
 
Marsh,

My combo box's Row Source is SELECT qryEmplyee.LastName
FROM qryEmplyee;
qryEmplyee is EmployeeID and LastName Ascending order by
LastName.

I have the Bound column set to zero. My VB code is:
Forms(frmEvent).Controls(cmbOpenedBy).ListIndex = 0

When I run it I get an error.

I also tried:
Me.cmbOpenedBy.ListIndex = 0

Do you see what I'm doing wrong?

Thanks

matt
 
Marsh,

I figured it out.

I needed to set the focus to the control first.

Thanks for you help.

Matt
 
Sorry, I should have mentioned that both the Text and Index
properties require that the control have the focus when you
assign their value (actually, the Text property is only
available when it has the focus).

Glad to hear you worked it out.
 
Back
Top