Create and delete table: refresh?? HELP!

ijergas

Registered User.
Local time
Today, 10:34
Joined
Oct 6, 2005
Messages
13
Hi,

A very wierd thing is now happening. When I create a table using the following code:

Myint = Me![Combo52]
strSQL = "SELECT [doctoremail].RESOURCE, [doctoremail].MRN, [doctoremail].D_FNAME, [doctoremail].D_LNAME, [doctoremail].P_FNAME, [doctoremail].P_LNAME INTO [Tbl_AttachPatients] FROM [doctoremail] WHERE [doctoremail].RESOURCE =" & Myint
DoCmd.RunSQL strSQL

RefreshDatabaseWindow

I then need to delete the table using:

Dim obj As AccessObject


For Each obj In Application.CurrentData.AllTables
If obj.Name = "Tbl_AttachPatients" Then
If obj.IsLoaded Then
DoCmd.Close acTable, "Tbl_AttachPatients", acSaveNo
End If
DoCmd.DeleteObject acTable, "Tbl_AttachPatients"
End If
Next obj

All of this happens in a loop. The wierd thing is that it work fine as long as the database window is displaying the "Tables" page (i.e. so you can actually see the table being created and deleted). But if the database window is closed or displaying a different page (Queries or Forms, etc..) I errors that either the table "already exists" (ie. the delete did not work) or that "no table exists" (i.e. that the make table did not work). It seems that the code can only reference the tables when they are actually visible in the database window.

Anyone have any thoughts on this?

Thank you so much,

Josh
 
Correction, if the database window is closed, it seems to work as well. Only when it is open and displaying a page other than the tables page...

Very frustrating, any help would be appreciated.

Thanks,

josh
 

Users who are viewing this thread

Back
Top Bottom