mfaqueiroz
New Member
- Joined
- Sep 30, 2015
- Messages
- 5
Hi,
I'm comparing two tables, A and B. I want when Painel it's the same in both tables and the difference of the time it's less then one minute give me the value of field [human] that belong to B table, and writes this value in my A table.
I wrote the following code, but isn't working... ..could you please help me!
I'm stuck
I really appreciate your dedication and time!
Private Sub OrdLigDesl()
Dim y As Integer
Dim x As Integer
Dim TempoLigDesl As Date
Dim TempoEvenLog As Date
Set dbs = DBEngine(0)(0)
Set A= dbs.OpenRecordset("A", DB_OPEN_TABLE)
Set B= dbs.OpenRecordset("B", DB_OPEN_TABLE)
contaA = DCount("[Painel]", "A")
contaB= DCount("[Painel]", "B")
x = 0
y = 0
A.MoveFirst
For y = 1 To contaA
TimeA= TimeValue(A.Fields(2).Value)
PainelA= A.Fields(5).Value
B.MoveFirst
For x = 1 To contaB
TempoB= TimeValue(B.Fields(1).Value)
PainelB = B.Fields(7).Value
Human = B.Fields(4).Value
If PainelA = PainelB And DateDiff("n", tempoA, tempoB) <= 1 Then
A.Edit
A.Fields(9).Value = Yes
A.Update
Else
End If
B.MoveNext
Next x
A.MoveNext
Next y
End Sub
I'm comparing two tables, A and B. I want when Painel it's the same in both tables and the difference of the time it's less then one minute give me the value of field [human] that belong to B table, and writes this value in my A table.
I wrote the following code, but isn't working... ..could you please help me!
I'm stuck
I really appreciate your dedication and time!
Private Sub OrdLigDesl()
Dim y As Integer
Dim x As Integer
Dim TempoLigDesl As Date
Dim TempoEvenLog As Date
Set dbs = DBEngine(0)(0)
Set A= dbs.OpenRecordset("A", DB_OPEN_TABLE)
Set B= dbs.OpenRecordset("B", DB_OPEN_TABLE)
contaA = DCount("[Painel]", "A")
contaB= DCount("[Painel]", "B")
x = 0
y = 0
A.MoveFirst
For y = 1 To contaA
TimeA= TimeValue(A.Fields(2).Value)
PainelA= A.Fields(5).Value
B.MoveFirst
For x = 1 To contaB
TempoB= TimeValue(B.Fields(1).Value)
PainelB = B.Fields(7).Value
Human = B.Fields(4).Value
If PainelA = PainelB And DateDiff("n", tempoA, tempoB) <= 1 Then
A.Edit
A.Fields(9).Value = Yes
A.Update
Else
End If
B.MoveNext
Next x
A.MoveNext
Next y
End Sub