Get Displayed Text of a ComboBox

  • Thread starter Thread starter David C. Holley
  • Start date Start date
D

David C. Holley

I've been playing with programically getting the text value of a ComboBox,
but I keep getting an error message that the control has to have the focus
in order to reference the .Text property. If I explicity set the focus, I'm
able to get the value without any problems.

Is this normal?
 
David C. Holley said:
I've been playing with programically getting the text value of a ComboBox,
but I keep getting an error message that the control has to have the focus
in order to reference the .Text property. If I explicity set the focus,
I'm able to get the value without any problems.

Is this normal?

In Access, the Text property represents the current contents of the control
before it is updated. When focus is lost (when you tab or click to another
control), the Value property contains the control's current, updated value.
So to refer to it when another control has the focus, use the Value property
(actually you can abbreviate that to just the control's name, because Value
is it's default property).
 
David C. Holley said:
I've been playing with programically getting the text value of a ComboBox,
but I keep getting an error message that the control has to have the focus
in order to reference the .Text property. If I explicity set the focus,
I'm able to get the value without any problems.

Is this normal?

For Access yes. If you know the ordinal position of the column being
displayed you can use...

Me.ComboBoxName.Column(n)

....where n is the zero-based position of the column you want.
 
Back
Top