JohnBoy2005
Programmer
How can I set the text value of a combo box, based on its itemdata value
e.g.
'initial populate of combo box
Dim rstSubject As Recordset
Set rstSubject = dbs.OpenRecordset("SELECT * FROM tblSubjects ORDER BY Subject ASC")
rstSubject.MoveLast
rstSubject.MoveFirst
Do Until rstSubject.EOF
cboSubject.AddItem UCase(rstSubject("Subject"))
cboSubject.ItemData(cboSubject.NewIndex) = rstSubject("Subject_ID")
rstSubject.MoveNext
Loop
'Set data in combobox
cboSubject = the subject_id from record in database
I've tried
cboSubject.ItemData(cboSubject.ListIndex) = rst("Subject_ID") but it returns the wrong value
Cheers
John
e.g.
'initial populate of combo box
Dim rstSubject As Recordset
Set rstSubject = dbs.OpenRecordset("SELECT * FROM tblSubjects ORDER BY Subject ASC")
rstSubject.MoveLast
rstSubject.MoveFirst
Do Until rstSubject.EOF
cboSubject.AddItem UCase(rstSubject("Subject"))
cboSubject.ItemData(cboSubject.NewIndex) = rstSubject("Subject_ID")
rstSubject.MoveNext
Loop
'Set data in combobox
cboSubject = the subject_id from record in database
I've tried
cboSubject.ItemData(cboSubject.ListIndex) = rst("Subject_ID") but it returns the wrong value
Cheers
John