ChewDoggie
Programmer
Hello All,
I have a Dictionary object that is Dimmed at the top of my form as "Dim DataCardCodes as Dictionary"
In the Form_Load Event, I have the following code:
Then in another Function in the same form, I have this code:
I'm just trying to retrieve the "value" (or item) of the Dictionary object. The above test passes (the code exists), but when I attempt to retrieve the value by passing in the Key, I receive an error, "Object is no longer valid".
Whaaaa???
Can anyone shed some light?
Thanks!
Chew
10% of your life is what happens to you. 90% of your life is how you deal with it.
I have a Dictionary object that is Dimmed at the top of my form as "Dim DataCardCodes as Dictionary"
In the Form_Load Event, I have the following code:
Code:
Set rsCodes = New ADODB.Recordset
sql = "select alphacode, rid from datacards where eventid = " & EventID & " order by alphacode"
rsCodes.open sql, cn
Set DataCardCodes = New Dictionary
Do While Not rsCodes.EOF
DataCardCodes.Add Trim(rsCodes!AlphaCode), rsCodes!rid
rsCodes.MoveNext
Loop
rsCodes.Close
Then in another Function in the same form, I have this code:
Code:
Private Function DataCardExists() As Boolean
Dim id as long
If DataCardCodes.Exists(Trim(txtCode.Text)) Then
DataCardExists = True
id = DataCardCodes(trim(txtCode.Text))
Else
DataCardExists = False
End If
End Function
I'm just trying to retrieve the "value" (or item) of the Dictionary object. The above test passes (the code exists), but when I attempt to retrieve the value by passing in the Key, I receive an error, "Object is no longer valid".
Whaaaa???
Can anyone shed some light?
Thanks!
Chew
10% of your life is what happens to you. 90% of your life is how you deal with it.