We help IT Professionals succeed at work.
Get Started

Table Getting locked when opening the applicaiton form

Last Modified: 2017-11-16
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:

Private Sub Form_Load()
Call Copy
End Sub

Open in new window

Sub Copy()
If DoesTblExist("LoadTableFinal") Then
CurrentDb.Execute "DROP TABLE LoadTableFinal", dbFailOnError
CurrentDb.Execute "SELECT [dbo_Load Table].* INTO LoadTableFinal FROM [dbo_Load Table];"
CurrentDb.Execute "SELECT [dbo_Load Table].* INTO LoadTableFinal FROM [dbo_Load Table];"
End If
End Sub

Open in new window

Function DoesTblExist(sTableName As String) As Boolean
   Dim db   As DAO.Database
   Dim tdf  As TableDef
On 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 exists
   On Error Resume Next
   Set tdf = Nothing
   Set db = Nothing
   Exit Function
   If Err.Number = 3265 Then
      'If we are here it is because the table could not be found
      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_Exit
End Function

Open in new window

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.
Watch Question
Most Valuable Expert 2015
Distinguished Expert 2018
This problem has been solved!
Unlock 3 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE