MS Access - SQL - "Syntax Error in FROM Clause"
Posted on 2007-08-02
I'm using Microsoft Access 2003. I have a form with a button. When I click the button I want to find a particular record and then delete it. I started with an ADODB Recordset open function using a select * from myTable where.... However, I had a syntax error. To try to eliminate my syntax problem, I removed the where clause, and simply using a select * from myTable. However, I'm still getting the error. The code is below. Since I'm trying to get the base SQL statement to work, I've commented out the delete command.
I have verified that I have a table named PropertyWorkOrder_JunctionTable in my database. I've also tried encasing my table name with brackets, but that didn't help either.
Private Sub RemoveFromWOBtn_Click()
On Error GoTo RemoveFromWOBtn_Click_Err
Dim rst As New ADODB.Recordset
Dim CurDB As Database
Set CurDB = CurrentDb
Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open "SELECT * FROM PropertyWorkOrder_JunctionTable", CurrentProject.Connection, , , adCmdTable
'rst.Open "SELECT * FROM PropertyWorkOrder_JunctionTable WHERE [WorkOrderID] = '" & _
' Forms!WO_Mainform!WorkOrderID & "'" & " AND [PropertyID] = '" & _
' Forms!RemovePropertyForm!PropertyID & "'", CurrentProject.Connection, , , adCmdTable
DoCmd.Close acForm, "RemovePropertyForm", acSaveYes