Question : Dictionary Object giving me a "No current record" error

I am trying to loop through a table and create a dictionary of the data.  I need to use that data (once I can read it).  Anyway, I am building the code and testing it as I go.  I have the following code.  At the end of the code is a For each key in keys loop.  The Debug.Print statement in that loop is failing and it is bugging me.  I get an error "No Current Record".  The Debug.Print "Dictionary Count = " & dct.Count statement is returning 30.  The debug statements within the nested if are all returning valid values.  Does anyone have any idea why my statement is failing?

Thank you in advance.

Tammy
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
Dim dct As Object
    Dim rst As Recordset
    Dim keys As Variant
    Dim key As Variant
    Dim strPreviousGUID As String
    
    Set dct = CreateObject("Scripting.Dictionary")
    Set rst = CurrentDb.OpenRecordset("CDM_Data")
    
    strPreviousGUID = ""
    
    With dct
        Do While Not rst.EOF
            If Nz(rst("BO-Identifier"), "") <> "" Then
                If (Not .Exists(Replace(rst("BO-Identifier"), "-", ""))) Then
                    Debug.Print "Previous GUID: " & strPreviousGUID
                    Debug.Print "Current GUID: " & rst("BO-Identifier")
                    .Add Replace(rst("BO-Identifier"), "-", ""), rst("BO-Description/Definition")
                    Debug.Print Replace(rst("BO-Identifier"), "-", "")
                End If
                strPreviousGUID = Nz(rst("BO-Identifier"), "")
            End If
            rst.MoveNext
        Loop
    End With
    
    Debug.Print "Dictionary Count = " & dct.Count
    
    keys = dct.keys
    
    For Each key In keys
        Debug.Print dct.Item(key)
    Next key
    
Exit_Sub:
    Exit Sub

Err_Handler:
    MsgBox Err.Description
    Debug.Print Chr(10)
    Debug.Print Err.Description
    Resume Exit_Sub

Answer : Dictionary Object giving me a "No current record" error

try

.Add Replace(rst("BO-Identifier"), "-", ""), rst("BO-Description/Definition")
-->
.Add (Replace(rst("BO-Identifier"), "-", ""), rst("BO-Description/Definition"))
Random Solutions  
 
programming4us programming4us