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

Combobox NewIndex problems

Status
Not open for further replies.

5ilversaracen

Programmer
Nov 21, 2009
5
GB
Hi
I'm developing an Access Application using Access 2002. I can't seem to populate ItemData in dropdown though. My code (which is triggered by the form onload event) is:

Combo0.AddItem "My string"
Combo0.ItemData(Combo0.NewIndex) = 2

The error I get is:

Method or Data Member not found

I have also tried:
Combo0.ItemData(Combo0.ListCount - 1) = 2
but that doesn't work either.

Has anyone got any ideas on this?
Many thanks in advance.

 
are you using a MSForms combobox control or an Access combobox? As the error says there is no such method with an Access combobox.

And do not even understand what you want to do. Do you want to add "2" as the last item in the list. Look at the second parameter of the additem method.
 
thanks for replying

how would I be able to find out which type of combo box I'm using?

My aim here is to have a combo box that shows string values from a recordset but also contains hidden ID values.
 
Unless you explicitly specified it is an Access combo.

In access a combo has these properties
column count:
column widths:

if I want two columns where the first is hidden
column count:2
column widths: 0";2.5"

to enter data into two columns seperate by ;
me.combo0.additem("My String;2")
 
many thanks MajP

the columns work perfectly. I guess I must have an Access combo.
 
You would know if you had an MS Forms control.
You would have had to purposely pick
"Insert additional active X controls"
and then scroll down to
MS Forms 2.0 Combobox

However, the MS Forms controls can be used on an access form and have some different useful properties that the native controls do not have. Sometimes you may want these features. I thought that was what you were trying in the original post.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top