Combo-Box Population

HotRod40

New member
Joined
Jun 8, 2004
Messages
2
Location
Manchester, UK
Programming Experience
1-3

Hi,

I am using a 'Sub Main' procedure on a module which is my startup module. This module reads a table and then populates a combo box on the main form. Whilst this is happening a splash screen is displayed to inform the user of loading. I can connect to my database OK and read records, but when I come to populate the combo box on my main form I get an error. I have created a new variable for my form but I dont see where the problem is. The loop I use is shown below. The loop is OK but the 'cbxAccount' object is not recognised. All works OK if I do this on the main form itself. Any help would be grateful. Thanks

The Error I receive is:

"Public member 'cbxAccount' on type 'MainForm' not found."

My Code is:

//Form variable (Global)
Public frmMain = New MainForm()

//other code....

Do


frmMain.cbxAccount.Items.Add(oSalesRecord.Fields.Item("account_ref").Value)

Loop Until Not oSalesRecord.MoveNext()
 
you have to instantiate the form first. If you'll notice, the standard "New" method for a form contains a call to the InitializeComponent method; this is where the comboBox will be created. If the form hasn't been created (instantiated) yet, the comboBox won't exist either.
 
Back
Top