G
Guest
I am receiving the error message "Invalid procedure call or argument" when I run the following command:
strSQL = Replace(strSQL, " FROM ", " INTO " & strTableName & " FROM ")
This line is meant to amend the following piece of SQL text in the string variable:
"SELECT s.SalesID FROM tblSales s WHERE s.fkCompanyID = 10"
Can anyone offer any assistance? Oddly, this line was working earlier but has since been refusing stubbornly. For reference, I will now list the rest of my code:
Function BuildResultsTable(strSQL As String, _
strTableName As String, _
lngRecordsAffected As Long) As Boolean
Dim db As Database
Dim qdfAction As QueryDef
Set db = CurrentDb
On Error Resume Next
db.TableDefs.Delete strTableName
On Error GoTo 0
strSQL = Replace(strSQL, " FROM ", " INTO " & strTableName & " FROM ")
Set qdfAction = db.CreateQueryDef("", strSQL)
qdfAction.Execute dbFailOnError
qdfAction.Close
BuildResultsTable = True
End Function
TIA.
strSQL = Replace(strSQL, " FROM ", " INTO " & strTableName & " FROM ")
This line is meant to amend the following piece of SQL text in the string variable:
"SELECT s.SalesID FROM tblSales s WHERE s.fkCompanyID = 10"
Can anyone offer any assistance? Oddly, this line was working earlier but has since been refusing stubbornly. For reference, I will now list the rest of my code:
Function BuildResultsTable(strSQL As String, _
strTableName As String, _
lngRecordsAffected As Long) As Boolean
Dim db As Database
Dim qdfAction As QueryDef
Set db = CurrentDb
On Error Resume Next
db.TableDefs.Delete strTableName
On Error GoTo 0
strSQL = Replace(strSQL, " FROM ", " INTO " & strTableName & " FROM ")
Set qdfAction = db.CreateQueryDef("", strSQL)
qdfAction.Execute dbFailOnError
qdfAction.Close
BuildResultsTable = True
End Function
TIA.