Re: check if a table is open
Quote:
Originally Posted by rochak
I have to close a table manually in vba.
Are you opening the table in vba??..
You can use the AllTables Collection to determine if the table is loaded and close it if it is..
VB Code:
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
If obj.Name = "Mailboxes" And obj.IsLoaded Then DoCmd.Close acTable, obj.Name
Next obj
Re: check if a table is open
Danny, thanks I just understood why my stuff was hanging. If I open the mailboxes table without vba, then your code works just fine. However, if I open the table using vba, it is then that my access project hangs. Can you please help me in this?
Re: check if a table is open
Rochak.
You will need to ensure that any references that you have set to things like, fields, or the table itself are cleared before closing the table..
Re: check if a table is open
Danny, I am using a switchboard which has two buttons. One button opens up the form which edits the records on the Mailboxes table. I am not doing this using any recordsets so that references problem is minimized. The second button runs a macro which displays the mailboxes table. If by any chance the first form remains open (user hasnot exit it) and at the same time he clicks on the macro button, the stuff simply hangs. Is there a way for the macro to work in conjunctions with the edit form. Thanks
Re: check if a table is open
Without taking a look at the Macro I will be stabbing in the dark, but my stab is that you can close the form and then open the table, however due to being unable to control the table closure you would be better off setting a form as datasheet view to display the table instead..