I made a SQL string and when I go to run it I get an error saying "A run SQL action requires an arguement consisting of an SQL statement." I pasted the SQL string in the SQL view and it ran fine. I'm hoping I am just missing something with text delims or something.
Here is the code that doesn't work.
Sub ADD_HRS()
Dim strSQL As String
strSQL = "SELECT sum([Hrs running prod]) " _
& " AS[xvar]" _
& " FROM tblprod" _
& " WHERE [Machine area] = 'TW10Y';"
DoCmd.RunSQL (strSQL)
MsgBox xvar
End Sub
Here is the SQL statement that produces a field with the correct value.
SELECT sum([Hrs running prod])
AS [xvar]
FROM tblprod
WHERE [Machine area ]= 'TW10Y';
Please let me know if I have enough info.
I have Access 2000 and Windows 2000.
Rib
Bartender:Hey aren't you that rope I threw out an hour ago?
Rope:No, I'm afraid knot.
Here is the code that doesn't work.
Sub ADD_HRS()
Dim strSQL As String
strSQL = "SELECT sum([Hrs running prod]) " _
& " AS[xvar]" _
& " FROM tblprod" _
& " WHERE [Machine area] = 'TW10Y';"
DoCmd.RunSQL (strSQL)
MsgBox xvar
End Sub
Here is the SQL statement that produces a field with the correct value.
SELECT sum([Hrs running prod])
AS [xvar]
FROM tblprod
WHERE [Machine area ]= 'TW10Y';
Please let me know if I have enough info.
I have Access 2000 and Windows 2000.
Rib
Bartender:Hey aren't you that rope I threw out an hour ago?
Rope:No, I'm afraid knot.