Update Display for Combo Box (1 Viewer)

Codexx

New member
Local time
Today, 15:03
Joined
Oct 26, 2015
Messages
3
I have a form with multiple combo boxes, these boxes have 2 column list where column 0 width is zero. All these boxes have row sources defined for their drop down list values.

When I try to over ride the display value of the combo boxes via vb code, it works for few of the controls while doesnt do anything for the rest. So I made an isolated code just to update values of all combo boxes(cbo) and again the same controls pass/fail. Here is the code I am trying to work with, can anyone please tell me why I am unable to update some combo boxes while others work fine?

Thanks

Code:
Sub test()

Dim Ctrl As Control
Dim CtrlName_Combined as String

For Each Ctrl In Forms("frmNewTransaction").Controls

'Name of all combo boxes start with 'cbo' 

If Left(Ctrl.Name, 3) = "cbo" Then
Ctrl = "Hello"
CtrlName_Combined = ctrlName_Combined & Ctrl.Name & " "
End If

Next Ctrl

MsgBox CtrlName_Combined

End Sub
 

Codexx

New member
Local time
Today, 15:03
Joined
Oct 26, 2015
Messages
3
They all show Unbound in Design view but have Bound Column = 1 in properties.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:03
Joined
May 7, 2009
Messages
19,229
do all have the word "Hello" on their list?
have you tried:

Forms("frmNewTransaction").Controls(ctrl.Name).Value = "Hello"
 

Codexx

New member
Local time
Today, 15:03
Joined
Oct 26, 2015
Messages
3
@Arnelgp Yea doesnt work that way either and None of them have Hello in the list items
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:03
Joined
May 7, 2009
Messages
19,229
none of them have hello, then what do you want then. do you want to add the word "hello" to your list:

Me.listControl.AddItem "Hello"

to select it after adding:

Me.listControl.Value = "Hello"
 

Users who are viewing this thread

Top Bottom