ComboBox itemData as Long => error

Hi,

I have a problem with a ComboBox. It is in fact a ListBox, containing String.

These String are getted from a database (Oracle 9i), and their ids are big (300 000 for example), which does nto fit in an Integer.

So when a do this :
Set rstListe = cmdDefliste.Execute
cmb_ListeOrg.Clear
If Not rstListe.EOF Then
Do While Not rstListe.EOF
cmb_ListeOrg.AddItem CStr(rstListe.Fields(1))
cmb_ListeOrg.ItemData(cmb_ListeOrg.NewIndex) = CInt(rstListe.Fields(0))

rstListe.MoveNext
Loop
Else
cmb_ListeOrg.AddItem "Aucun organisme trouve"
End If

I have an error saying that I have a "depassement de capacite" in french, so that the capacity of itemData is too small.

How could I put Long in my ComboBox

Thanks.


Answer this question

ComboBox itemData as Long => error

  • petedashwood

    The error is occuring because you're passing a value to CInt() which is too large to be represented by the Integer data type. Change "CInt(rstListe.Fields(0))" to "CLng(rstListe.Fields(0))" and I bet that'll fix it for you.



  • Mamine

    Thanks very much :)

    It was easy, but I'm on it since several hours :P

  • ComboBox itemData as Long => error