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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pausing Code until Table closes 1

Status
Not open for further replies.

BPhilb

Programmer
Feb 25, 2002
29
0
0
US
I have a function written in which I want a table to open and the code to halt until the table is closed. It's a rather long program but just to give an idea of where I am at here is some sample code:

Function Check()
Dim db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("Table1")
DoCmd.OpenTable "Table1", acViewNormal, acEdit

Do Until rst
Loop

DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "Table1"
DoCmd.SetWarnings True

End Function

I will be writing the data to another table later (not shown here) but I want the user to have access to this data before it deletes. If there anything I can do to pause the code until Table 1 is closed? Thanks for your help.
 
Hi,

It's not very clear.

You want access to the data before it deletes, and you want to pause the code until the table is closed.

Which is it?
How long the delay?

i.e. If the table is deleted in milliseconds naturally, then the user won't have time to see the data in any case - so how long the delay?

If you don't want the table to be deleted before the user has finished, then don't delete it until the user decides it.

Or have I got it wrong?

Regards,

Darrylle
"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Darrylle,

Your right. I don't want it deleted until the user closes the table. You say that I shouldn't delete the table until the user decides. How do I do that? I have my delete line after I open the table but once the table opens the code just continues running. I hope this makes more sense. Thanks for your response.

Brad
 
Hi BP,

OK.

Copy this code:

DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "Table1"
DoCmd.SetWarnings True

and paste it into the 'on_click' event of a new button (you name it how you wish, it will delete a table when clicked).

Comment out (using ' ) or delete this code from the Check() function .

Now when the Check function runs, it won't delete the table.

When the user is ready to delete the table - he/she clicks your new button.

(I don't like deleting tables in code - dangerous. Please backup your whole database before taking this advice).

This work for ya?

Regards,

Darrylle



"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Darryless,

I never thought about running it that way. That will be perfect. I am writing a program in which users scan books as part of a quality check as opposed to counting them by hand. It's a small step on there part but will give me exactly what I need. I'm actually going to write a form later which will make this easier but the program is being released before it's totally ready. Thank you again for your help.

Brad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top