I have the following Query from an Access Query Builder and it works fine.
please note that the tbl36hrWeekRoster table is a table that contains only dates and is joined to nothing. (I only included to be able to give me a Date Field).
I need to run from a button on a form.
Working Query:
Non Working VBA Verson:
I am getting the following error:
Is there another way to run the Access Query from the form
please note that the tbl36hrWeekRoster table is a table that contains only dates and is joined to nothing. (I only included to be able to give me a Date Field).
I need to run from a button on a form.
Working Query:
Code:
INSERT INTO tblRosterRec ( Date_, FctnID, EmpId, Name )
SELECT tbl36hrWeekRosters.Date_, tblFunctions.ReliefCode, qryAllocated.EmpId, qryAllocated.Name
FROM tbl36hrWeekRosters, qryAllocated INNER JOIN tblFunctions ON qryAllocated.FctnDesc = tblFunctions.FctnDesc
WHERE tbl36hrWeekRosters.Date_=[Forms]![Form1]![txtDate];
Non Working VBA Verson:
Code:
Set dbs = CurrentDb
Dim sSQL As String
strSQL = "INSERT INTO tblRosterRec ( Date_, FctnID, EmpId, Name ) " & _
"SELECT tbl36hrWeekRosters.Date_, tblFunctions.ReliefCode, qryAllocated.EmpId, qryAllocated.Name " & _
"FROM tbl36hrWeekRosters, qryAllocated INNER JOIN tblFunctions ON qryAllocated.FctnDesc = tblFunctions.FctnDesc " & _
"WHERE tbl36hrWeekRosters.Date_=#" & Me.txtDate & "#;"
dbs.Execute (sSQL)
I am getting the following error:
Is there another way to run the Access Query from the form