mfaqueiroz
Registered User.
- Local time
- Today, 08:09
- Joined
- Sep 30, 2015
- Messages
- 125
Hello!
I recently discovered that using SQL in vba is much more efficient.
I'm searching for a way to transfer information to other table using SQL as well as running some simple cycles.
So, giving an simple example that everyone could understand:
I have two tables one with colours and code of object and other only with objects, I want to complete the second table with the right colour and code of object.
Set Tab1= dbs.OpernRecordset("Tabcolour", DB_OPEN_TABLE)
Set Tab2= dbs.OpernRecordset("TabObjects", DB_OPEN_TABLE)
Tab1.MoveFirst
While not Tab1.EOF
Colour= tab1.Fields(1).Value
Object=tab1.Fields(2).Value
Code=tab1.Fields(3).Value
Tab2.MoveFrist
Whil not Tab2.EOF
Object2=tab2.Fields(1).Value
If Object2=Object1 Then
Tab2.Edit
Tab2.Fields(2).Value= Colour
Tab2.Fields(3).Value = "Check"
Tab2.Fields(4).Value= Code
Tab2.Update
End If
Tab2.MoveNext
Loop
Tab1.Movenext
loop
End Sub
Do you have any suggestion how can i do that on Sql?
I'm vere grateful for any help that you can give me.
I wish a good start of the year to all
I recently discovered that using SQL in vba is much more efficient.
I'm searching for a way to transfer information to other table using SQL as well as running some simple cycles.
So, giving an simple example that everyone could understand:
I have two tables one with colours and code of object and other only with objects, I want to complete the second table with the right colour and code of object.
Set Tab1= dbs.OpernRecordset("Tabcolour", DB_OPEN_TABLE)
Set Tab2= dbs.OpernRecordset("TabObjects", DB_OPEN_TABLE)
Tab1.MoveFirst
While not Tab1.EOF
Colour= tab1.Fields(1).Value
Object=tab1.Fields(2).Value
Code=tab1.Fields(3).Value
Tab2.MoveFrist
Whil not Tab2.EOF
Object2=tab2.Fields(1).Value
If Object2=Object1 Then
Tab2.Edit
Tab2.Fields(2).Value= Colour
Tab2.Fields(3).Value = "Check"
Tab2.Fields(4).Value= Code
Tab2.Update
End If
Tab2.MoveNext
Loop
Tab1.Movenext
loop
End Sub
Do you have any suggestion how can i do that on Sql?
I'm vere grateful for any help that you can give me.
I wish a good start of the year to all