Combo.ItemData maximum value
Hi all
First of all, sorry for my poor english writing.
My question is:
Why I can NOT set the value "11001000000" to one of combo items as its ItemData value?
I mean:
With Recordset1
.Sort = "ID Asc"
.MoveFirst
While Not .EOF
sItem = .Fields("Code") & " - " & .Fields("Name")
Combo1.AddItem (sItem)
Combo1.ItemData(Combo1.NewIndex) = .Fields("ID")
.MoveNext
Wend
End With
Now, VB 6.0 compiler shows me "Overflow 6" error message for the line "Combo1.ItemData(Combo1.NewIndex) = .Fields("ID") " when .Fields("ID") has the value equal to 11001000000.
How can I solve this problem?
Re: Combo.ItemData maximum value
If the value in ID is meant to be a decimal numeric, it overflows the ItemData() capacity, which, as far as I know, is limited to Long, that is +/- 2^31
The value of 11001000000 can be represented by a Double.
The first idea come to mind is, you have to maintain a (dynamic) array of Doubles which holds the ID.
Re: Combo.ItemData maximum value
Thank you WoF for your attention,
But how can I use the dynamic array that you said with the combo that has been filled by a recordset?
Re: Combo.ItemData maximum value
What's the data type in the DB? That's what you'd change.
Re: Combo.ItemData maximum value
@dglienna:
Well, as I mentioned in my first post, the recordset which my combo will be filled by has 3 column: ID (bigint) , Name (varchar(50)) and code (char(9)).
The combo will be filled by it in order that ID will be itemData of every item and I use Code+ --+Name as displayValue
but it seems that the value
11001000000
can not be set as itemdata
how can I solve this problem?
thank you
Re: Combo.ItemData maximum value
How can it fit in 9 characters?
Looks like 11 to me
Re: Combo.ItemData maximum value
@ dglienna:
11001000000 is not code. It's ID which will be used as itemdata of every item in combo.
Re: Combo.ItemData maximum value
Hi odiseh
property ItemData is datatype Long, the value that you want to set it's not posible
11001000000 is out range to Long.
so I time ago used work :
Code:
With Recordset1
.Sort = "ID Asc"
.MoveFirst
While Not .EOF
sItem = .Fields("Code") & " - " & .Fields("Name")
Combo1.AddItem (sItem)
if combo1.tag="" then
combo1.tag=cstr( .Fields("ID"))
else
combo1.tag=combo1.tag & "," & cstr( .Fields("ID"))
end if
.MoveNext
Wend
End With
and you could get to get the value as :
Code:
dim v() as string
v = Split(combo1.tag, ",")
Debug.Print v(combo1.ListIndex)
I hope this is useful
Re: Combo.ItemData maximum value
@hensa22:
hi :)
Thanks alot for your attention. Your solution seems to be correct and is a nice way. I'll try it in my project. Thank you very much
Re: Combo.ItemData maximum value
Nice idea, yes. Only watch that you don't use the .Sort option in the Combobox, because this will then mix up the relation item<->ID