Hi All
As an example I have 2 master records with 6 and 2 child records respectively selected from a recordset and want to get the counts of master and child into a dictionary to use in calculations later:
Weirdly i get:
as the debug output, I have no idea where that first dictionary key is coming from, it shouldn't exist as its the same as the second 1.
Anyone got any ideas what i'm doing wrong, never seen this before and i've used dictionaries before and not had an issue so i'm sure i'm doing something stupidly wrong
Thanks in advance
Glen
As an example I have 2 master records with 6 and 2 child records respectively selected from a recordset and want to get the counts of master and child into a dictionary to use in calculations later:
Code:
Set rs = Form.Recordset.Clone
With rs
.MoveFirst
Do While Not .EOF
delProdID = !del_prod_id
If Me.txtSelected Like "*," & delProdID & ",*" Then
consID = !cons_id
If Dict_consDeliveryNumbers.Exists(consID) = False Then
Dict_consDeliveryNumbers.Add Key:=consID, Item:=1
Else
Dict_consDeliveryNumbers(consID) = Dict_consDeliveryNumbers(consID) + 1
End If
End If
.MoveNext
Loop
.MoveFirst
End With
Dim consSplitAmount As Double
consSplitAmount = Me.txtTotalAmount / Dict_consDeliveryNumbers.Count
For Each iKey In Dict_consDeliveryNumbers.Keys
Debug.Print "!!!" & iKey & "!!!", Dict_consDeliveryNumbers(iKey)
'Debug.Print "For Consignment: " & iKey & " the amount for each of the " & CStr(Dict_consDeliveryNumbers(iKey)) & " deliveries would be: " & CStr(consSplitAmount / CInt(Dict_consDeliveryNumbers(iKey)))
Next iKey
Weirdly i get:
Code:
!!!34283!!!
!!!34283!!! 6
!!!34285!!! 2
as the debug output, I have no idea where that first dictionary key is coming from, it shouldn't exist as its the same as the second 1.
Anyone got any ideas what i'm doing wrong, never seen this before and i've used dictionaries before and not had an issue so i'm sure i'm doing something stupidly wrong
Thanks in advance
Glen