mfaqueiroz
Registered User.
- Local time
- Yesterday, 23:28
- Joined
- Sep 30, 2015
- Messages
- 125
Hello,
I've a Totals Query grouped by:
-Day
-Hour
-Minute
-Second
-Machine
and counts the number of "Alarms".
I want to flag the cases where at in the exact time (day,hour,minute,second) i've alarms in different machines.
Day=day
minute=minute
Second=second
Machine <>Machine
Do you have ideia how can i do that efficiently?
I've replicated the table as shows the follow code, but i think that are a cleaver way to do that, do you have suggestions?
I've a Totals Query grouped by:
-Day
-Hour
-Minute
-Second
-Machine
and counts the number of "Alarms".
I want to flag the cases where at in the exact time (day,hour,minute,second) i've alarms in different machines.
Day=day
minute=minute
Second=second
Machine <>Machine
Do you have ideia how can i do that efficiently?
I've replicated the table as shows the follow code, but i think that are a cleaver way to do that, do you have suggestions?
Code:
Sub Alarms()
Dim hour As String
Dim minute As String
Dim Second As String
Dim Machine As String
Set dbs = DBEngine(0)(0)
Set CountAlarms1 = dbs.OpenRecordset("CountAlarms1", DB_OPEN_DYNASET)
Set CountAlarms2 = dbs.OpenRecordset("CountAlarms2", DB_OPEN_DYNASET)
CountAlarms1.MoveFirst
Do while not CountAlarms1.EOF
Day=CountAlarms1.Fields(0)
Hour=CountAlarms1.Fields(1)
Minute=CountAlarms1.Fields(2)
Second=CountAlarms1.Fields(3)
Machine=CountAlarms1.Fields(4)
CountAlarms2.MoveFirst
Do while not CountAlarms2.EOF
Day1=CountAlarms2.Fields(0)
Hour1=CountAlarms2.Fields(1)
Minute1=CountAlarms2.Fields(2)
Second1=CountAlarms2.Fields(3)
Machine1=CountAlarms2.Fields(4)
If day1=Day and hour1=hour and minute1=minute and second1=second and machine1<>machine than
CountAlarms1.Edit
CountAlarms1.Fields(5)="Yes"
CountAlarms1.Update
End if
CountAlarms2.MoveNext
Loop
CountAlarms1.MoveNext
Loop
end sub