HI
I have created a dictionary with the help of you guys. But I am still a little confused as how these things really hang together. I have created a dictionary fine. The data I have contains just a name and a value
e.g.
"Name" "Total"
IA/R1 3434
IA/R1 4343
I have used the following to create this
and use this to retrieve the data into a form I use
??? Does this create 1 dictionary, with the values are inside.
e.g.
-dLine5----------
| |
| IA/R1 3434 |
| IA/R2 4343 |
| ....... |
-----------------
or a dictionary for each value e.g. IA/R1 & IA/R2 ....
?????????????????
I have now created another dictionary where I want to store 2 values relating to diebacks
e.g.
"var1" "Duration" "Total"
1A-D1 4235 33
1A-D2 3323 23
1B-D1 33 53
so I have created the following
How do I retrieve the data from the dictionary ??
and how is it stored ??
I know I'm asking alot but would appreciate any help in visualizing how they are created.
Thanks
Phil
I have created a dictionary with the help of you guys. But I am still a little confused as how these things really hang together. I have created a dictionary fine. The data I have contains just a name and a value
e.g.
"Name" "Total"
IA/R1 3434
IA/R1 4343
I have used the following to create this
Code:
Public Function Create_Dictionary_dLine5()
Dim dbsCurrent As Database
Set dbsCurrent = CurrentDb
Set dLine5 = New Scripting.Dictionary
Set rstLine5 = dbsCurrent.OpenRecordset( _
"SELECT IDATE, DISPLAYNAME, Sum(TAGVALUE) AS Total, ID " _
& "FROM TMP_Daily_Table " _
& "WHERE IDATE LIKE #" & G_DATE & "# AND DISPLAYNAME Like ""To*"" Or DISPLAYNAME Like ""Lev*""" _
& "GROUP BY IDATE, DISPLAYNAME, ID ", dbOpenDynaset)
With rstLine5
.MoveLast
.MoveFirst
Do While Not .EOF
Tmp_Name = !DISPLAYNAME
Tmp_Val = !Total
dLine5.Add Tmp_Name, Tmp_Val
.MoveNext
Loop
End With
and use this to retrieve the data into a form I use
Code:
For Each strKey In dLine5.Keys
Forms!DA_DAILY_Summary.Controls(strKey).Value = dLine5.Item(strKey)
Next
??? Does this create 1 dictionary, with the values are inside.
e.g.
-dLine5----------
| |
| IA/R1 3434 |
| IA/R2 4343 |
| ....... |
-----------------
or a dictionary for each value e.g. IA/R1 & IA/R2 ....
?????????????????
I have now created another dictionary where I want to store 2 values relating to diebacks
e.g.
"var1" "Duration" "Total"
1A-D1 4235 33
1A-D2 3323 23
1B-D1 33 53
so I have created the following
Code:
Public Function Create_Dictionary_dDieBacks()
Dim dbsCurrent As Database
Set dbsCurrent = CurrentDb
Set dDiebacks = New Scripting.Dictionary
Set dAttrList = New Scripting.Dictionary
'===============================================================================
' Create Recordset For DIEBACKS and Populate DICTIONARY
'===============================================================================
Set rstDIE = dbsCurrent.OpenRecordset( _
" SELECT Sum(dur) AS Duration, msg, var1, Count(msg) AS Total " _
& "FROM L123_ALARMS " _
& "GROUP BY msg, var1, CDate(Format([itime],""dd/mm/yyyy""))" _
& "HAVING (((msg) Like ""*In Dieback*"") AND ((CDate(Format([itime],""dd/mm/yyyy""))) Like #4/20/2004#))", dbOpenDynaset)
With rstDIE
.MoveLast
.MoveFirst
Do While Not .EOF
dKey = .Fields("var1")
dDiebacks.Add dKey, dAttrList
dDiebacks(dKey)("Duration") = .Fields("Duration")
dDiebacks(dKey)("Total") = .Fields("Total")
.MoveNext
Loop
End With
How do I retrieve the data from the dictionary ??
and how is it stored ??
I know I'm asking alot but would appreciate any help in visualizing how they are created.
Thanks
Phil