my code is having an error "invalid sql statement expected 'delete' 'insert'"
Here's my code;
I did a search on the internet regarding this and found-out that the error had something to do with the query
so I change it to
based on the suggested syntax on the internet.
Now, when I run the code again its having a different error now "The microsoft office access database engine cannot find the input table or query 'Beam'. Make sure it exists and that its name is spelled correctly."
The thing is theres a Table 'Beam Forces' in the access file. Would it be possible the code doesn't recognize 2 worded query?
Could anyone help me on this? Thanks :)
Here's my code;
Code:
Sub GetMyData()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sQRY As String
Dim strFilePath As String
strFilePath = "C:\Document\Parkside.mdb"
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset
Sheet2.Range("A1").ClearContents
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & strFilePath & ";"
sQRY = "Beam Forces"
rs.CursorLocation = adUseClient
rs.Open sQRY, cnn, adOpenStatic, adLockReadOnly
Application.ScreenUpdating = False
Sheet2.Range("B2").CopyFromRecordset rs
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
Exit Sub
End Sub
Code:
sQRY = "Beam Forces"
Code:
sQRY = "SELECT * FROM Beam Forces"
Now, when I run the code again its having a different error now "The microsoft office access database engine cannot find the input table or query 'Beam'. Make sure it exists and that its name is spelled correctly."
The thing is theres a Table 'Beam Forces' in the access file. Would it be possible the code doesn't recognize 2 worded query?
Could anyone help me on this? Thanks :)
Comment