Hi All
If I have some SQL code like this:
Code:
INSERT INTO tbl_Changes ( HB, Finished )
SELECT tbl_Main.HB, tbl_Main.Finished
FROM tbl_Main RIGHT JOIN tbl_Import_TEMP ON tbl_Main.HB = tbl_Import_TEMP.HB
WHERE tbl_Main.Finished<>tbl_Import_TEMP.Finished
How do I write this into VBA in a Access Module?
Like I tried this but I think I have messed it up:
Code:
Sub test()
Dim strSQL As String
strSQL = "INSERT INTO ChangesTB ( HB, Status, ETA) SELECT Main.HB, Main.Status FROM Main RIGHT JOIN UpdateTB ON Main.HB = UpdateTB.HB WHERE Main.Status<>UpdateTB.Status"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Exit_Command2_Click:
Exit Sub
End Sub
I've edited the code a bit to match actual tables and fields, though I might have messed that up also.
Thanks