Table Getting locked when opening the applicaiton form
i have an access application on form load i have this particular code that checks if a certain table exists if it does then drop it and insert into it making it a new table, if it doesn't exist then just insert into the table. but when i run the form itself it says:
Sub Copy()If DoesTblExist("LoadTableFinal") ThenCurrentDb.Execute "DROP TABLE LoadTableFinal", dbFailOnErrorMe.RefreshCurrentDb.Execute "SELECT [dbo_Load Table].* INTO LoadTableFinal FROM [dbo_Load Table];"Me.RequeryElseCurrentDb.Execute "SELECT [dbo_Load Table].* INTO LoadTableFinal FROM [dbo_Load Table];"Me.RequeryEnd IfEnd Sub
Function DoesTblExist(sTableName As String) As Boolean Dim db As DAO.Database Dim tdf As TableDefOn Error GoTo Error_Handler 'Initialize our variable DoesTblExist = False Set db = CurrentDb() Set tdf = db.TableDefs(sTableName) DoesTblExist = True 'If we made it to here without triggering an error 'the table existsError_Handler_Exit: On Error Resume Next Set tdf = Nothing Set db = Nothing Exit FunctionError_Handler: If Err.Number = 3265 Then 'If we are here it is because the table could not be found Else MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _ Err.Number & vbCrLf & "Error Source: DoesTblExist" & vbCrLf & "Error Description: " & _ Err.Description, vbCritical, "An Error has Occured!" End If Resume Error_Handler_ExitEnd Function
is there a way i can load the application deleting all the locks via code if not what is causing the table to be locked without any activity performed on it.