Hello
Could someone please help with what should be a very 'simple' procedure?(!!).
The update qry works perfectly within the query grid, ie writes the rq'd info into one tbl, based on data from another tbl. However - need to run this within VBA, (on user clicking button from front-end form).
Initally the following was used:
DoCmd.RunSQL " UPDATE tblA
INNER JOIN tblB '_
ON tblA.FileX = tblB.FileX '_
SET tblB.CalcDate2 = DateAdd("m",9,[tblA].[Date1]), '_
tblB.CalcDate3 = DateAdd("m",15,[tblA].[Date1]);"
Then, following 'nickjar2''s response to LizardKingSchwing this morning, I used the following alternative method:
Dim CalcDateSQL As String
Dim db As Database
Set db = CurrentDb
CalcDateSQL = "UPDATE tblA
INNER JOIN tblB '_
ON tblA.FileX = tblB.FileX '_
SET tblB.CalcDate2 = DateAdd("m",9,[tblA].[Date1]), '_
tblB.CalcDate3 = DateAdd("m",15,[tblA].[Date1]);"
db.Execute (CalcDateSQL)
Set db = Nothing
db.Close
On both occasions, I receive the error msge:
"Compile error:
Expected: end of statement"
This should be very trivial to solve, but for the life of me, I cannot see the error!
(I DO need to run this qry from the front-end form, to populate a text field with a calculated date. I don't wish to change the query, as it works fine).
Please help
Cheers, Magnetar
Could someone please help with what should be a very 'simple' procedure?(!!).
The update qry works perfectly within the query grid, ie writes the rq'd info into one tbl, based on data from another tbl. However - need to run this within VBA, (on user clicking button from front-end form).
Initally the following was used:
DoCmd.RunSQL " UPDATE tblA
INNER JOIN tblB '_
ON tblA.FileX = tblB.FileX '_
SET tblB.CalcDate2 = DateAdd("m",9,[tblA].[Date1]), '_
tblB.CalcDate3 = DateAdd("m",15,[tblA].[Date1]);"
Then, following 'nickjar2''s response to LizardKingSchwing this morning, I used the following alternative method:
Dim CalcDateSQL As String
Dim db As Database
Set db = CurrentDb
CalcDateSQL = "UPDATE tblA
INNER JOIN tblB '_
ON tblA.FileX = tblB.FileX '_
SET tblB.CalcDate2 = DateAdd("m",9,[tblA].[Date1]), '_
tblB.CalcDate3 = DateAdd("m",15,[tblA].[Date1]);"
db.Execute (CalcDateSQL)
Set db = Nothing
db.Close
On both occasions, I receive the error msge:
"Compile error:
Expected: end of statement"
This should be very trivial to solve, but for the life of me, I cannot see the error!
(I DO need to run this qry from the front-end form, to populate a text field with a calculated date. I don't wish to change the query, as it works fine).
Please help
Cheers, Magnetar