Link to home
Start Free TrialLog in
Avatar of JayceW
JayceWFlag for United Kingdom of Great Britain and Northern Ireland

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
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayceW

ASKER

Thanks for the speedy response Capricorn1 but sadly no joy. Now I get the error "Run-time error '3709': The search key was not found in any record

Even though the value populating the tblName variable does exist in the database.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayceW

ASKER

Even though the code is more efficent sadly the same error is still returned
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayceW

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_all")
   Set x = db.Execute("SELECT TOP 1 last_modified_date FROM tblPM_all Order by last_modified_date DESC;")
End Function
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayceW

ASKER

The module was called modImportData and changing that to modiDate had no impact
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayceW

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
Avatar of JayceW

ASKER

I meant to close with Capricorn1's response being the correct closure option