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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable ComboBox name - Word

Status
Not open for further replies.

nochoice

Programmer
Jun 17, 2003
72
CA
Hello,

I have a variable:

name_combo = "ComboBox1"

I want to do this:

name_combo.AddItem CheckBox1.Caption

I keep getting this:

Run-time Error '424':

Object required

I realize that VB considers the variable 'name_combo' as an object that doesn't exist. What can I do to fix my problem? Is there a special declaration?

Thanks in Advance,
NoChoice
 
Is the name of your combo box actually name_combo?? If so the name_combo.additem checkbox1.caption should work fine.

Im not sure what you are doing with the
name_combo = "ComboBox1"

waht did you declare name_combo as?? You can declare it as an object and than with a set statment make it into a combo box object, but simply the above code will not do it.
 
name_combo is a variable name, ComboBox1 is the ComboBox name

I'll try declaring it as an object.

I'll let you know how it goes,

Thanks
 
why not simply use the combo box name and add the items to it

ComboBox1.additem CheckBox1.caption

??
 
It has to be variable, because it's not actually "ComboBox1" it changes based on which checkbox is checked. for example:

if a checkbox starting with "aaa" is checked then it should add item to Combobox: "CBaaa"

if a checkbox starting with "bbb" is checked then it should add item to Combobox: "CBbbb"

I don't know if this is any clearer, but I have managed to work around this so what I want to do functions. It would be nice, however, if I could make it cleaner.

Thanks for your help,
NoChoice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top