JayceW
asked on
Troubleshoot "Run Time error '3295' Syntax error in DROP table or DROP index
I have added the below code to remove spurious table in my access database created when am import script is executed. Sadly when I try and run my function I get an error stating
"Run Time error '3295' Syntax error in DROP table or DROP index" I don't know why this is happening and am looking for some assiatance in troubleshooting it
Public Function DeleteImportErrorTbls()
'************************* ********** ********** ********** ********** ********** ********** ********** *
' This function stops the database getting cluttered up by removing any import error tables
'************************* ********** ********** ********** ********** ********** ********** ********** *
Dim tdf As TableDef
Dim db As Database
Dim tblName As String
Set db = CurrentDb
For Each tdf In CurrentDb.TableDefs
If Right(tdf.Name, 12) = "ImportErrors" Or Right(tdf.Name, 13) = "ImportErrors1" Then
'DoCmd.DeleteObject acTable, tdf.Name
tblName = tdf.Name
db.Execute "DROP TABLE " & tblName & ";"
'DoCmd.DeleteObject acTable, tdf.Name
End If
Next tdf
End Function
"Run Time error '3295' Syntax error in DROP table or DROP index" I don't know why this is happening and am looking for some assiatance in troubleshooting it
Public Function DeleteImportErrorTbls()
'*************************
' This function stops the database getting cluttered up by removing any import error tables
'*************************
Dim tdf As TableDef
Dim db As Database
Dim tblName As String
Set db = CurrentDb
For Each tdf In CurrentDb.TableDefs
If Right(tdf.Name, 12) = "ImportErrors" Or Right(tdf.Name, 13) = "ImportErrors1" Then
'DoCmd.DeleteObject acTable, tdf.Name
tblName = tdf.Name
db.Execute "DROP TABLE " & tblName & ";"
'DoCmd.DeleteObject acTable, tdf.Name
End If
Next tdf
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Even though the code is more efficent sadly the same error is still returned
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok so I am attempting what you suggested and the only error that I am getting is one regarding another function ehere to be honest I am a little confused as to why an error is being returned. Can you help?
The error being returned is:
"Expected function or variable"
Public Function iDate()
Dim db As DAO.Database, tb As DAO.Recordset, x As Variant
Set db = CurrentDb
Set tb = db.OpenRecordset("tblPM_al l")
Set x = db.Execute("SELECT TOP 1 last_modified_date FROM tblPM_all Order by last_modified_date DESC;")
End Function
The error being returned is:
"Expected function or variable"
Public Function iDate()
Dim db As DAO.Database, tb As DAO.Recordset, x As Variant
Set db = CurrentDb
Set tb = db.OpenRecordset("tblPM_al
Set x = db.Execute("SELECT TOP 1 last_modified_date FROM tblPM_all Order by last_modified_date DESC;")
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The module was called modImportData and changing that to modiDate had no impact
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have changed to
.OpenrecordSet and it seems no longer returns an Error in the debug menu.
And the original error is also resolved.
Thanks for your assistance
.OpenrecordSet and it seems no longer returns an Error in the debug menu.
And the original error is also resolved.
Thanks for your assistance
ASKER
I meant to close with Capricorn1's response being the correct closure option
ASKER
Even though the value populating the tblName variable does exist in the database.