Hi.
I've got some code that's trying to set the "selected" property in a listbox to highlight the relevant value returned from a recordset. Here's the relevant code.
[CODE]
sqlstr = "select * from location where location_name = '" & Me.txt_location_name & "'"
Set dbname = CurrentDb
Set loc_data = dbname.OpenRecordset(sqlstr)
loc_data.MoveFirst
For Each ctrl In Me.Controls
If ctrl.ControlType = acListBox Then
For kount = 0 To ctrl.ListCount - 1
If ctrl.Name = "lst_location_type" Then
If ctrl.ItemData(kount) = loc_data.Fields("loc_type") Then
ctrl.Selected(kount) = True
Exit For
End If
[END CODE]
The problem I'm getting, is that when I run it, although If ctrl.ItemData(kount) shows up as 1 and loc_data.Fields("loc_type") shows as "1", they're not equal and it drops through.
I've tried using the Str() function, but no dice.
Any ideas?
Cheers.