Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check in Access table is open

Status
Not open for further replies.

Fred48

Programmer
Feb 23, 2004
62
US
I am running into a problem when trying to DROP a table. I get a RTE saying the table is being used by another user or another process.

The process is to print an Access table it works the first time but if you try to print immediately print the table again is when the RTE occurs. When the printing is completed I close the table and set it to nothing. I tried doing a dispose and it did not help.

A snipet of the code is below only because the process is lenghtly:

In module InquriyUpdate - Procedure PrintEntireReport_FOR

Call Call Printer_PrintDatabaseTableADO

In module Global2 - Procedure rinter_PrintDatabaseTableADO

Do all format and print Table
close and set Table to nothing

In module InquriyUpdate - Procedure PrintEntireReport_FOR

After return call procdure to Drop Table the code is below:

cnn = New OleDbConnection(PrepareDBConnectStr(AppDir & TKWINS_MDB))
cnn.Open()

cmd = New OleDbCommand("DROP TABLE tblTempPrint", cnn)
drReader = cmd.ExecuteReader

When this executes the tblTempPrint get the RTE.

That is what I think I need to check if table is open or is there something else I can use.

Thanks.
 
Code:
       cmd = New OleDbCommand("DROP TABLE   tblTempPrint", cnn)
        cmd.ExecuteNonQuery()

Also try to use the TRY CATCH block
Code:
        Try
            Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\mydb.mdb;User Id=admin;Password=;")
            Dim cmd As New OleDb.OleDbCommand("DROP TABLE mytable", conn)
            conn.Open()
            cmd.ExecuteNonQuery()
            conn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

Zameer Abdulla
 
Have you tried executing the cmd object directly?
Code:
  cmd.ExecuteNonQuery

Regards
 
Hi,

thanks for all the comments. I changed the code around and it solved my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top