473,898 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting temporary tables

When leaving the main menu form I want to delete some temporary tables. The
following code on the form's close works: DoCmd.DeleteObj ect acTable,
"tmpEnvelop ". But is it possible to change it so that it deletes all tables
starting with tmp?
Thanks,
john
Sep 2 '06 #1
4 9860
How I would do this is to create a new module and paste the following:

'************** Code Start********** *****
Sub Delete_Temp_Tab les()

Dim Rst As DAO.Recordset
Dim StrSql As String

'Create a recordset containing table names beginning with 'TMP'
StrSql = "SELECT MSysObjects.Nam e " & _
"FROM MSysObjects " & _
"WHERE (((MSysObjects. ParentId) = 251658241)) " & _
"GROUP BY MSysObjects.Nam e " & _
"HAVING (((MSysObjects. Name) Like 'tmp*'));"

Set Rst = CurrentDb.OpenR ecordset(StrSql , , dbReadOnly)

With Rst
Do While Not .EOF
DoCmd.DeleteObj ect acTable, !Name
.MoveNext
Loop
End With

Rst.Close
End Sub
'************** Code End************ ***

Then on the 'Unload' event of your main menu form, simply enter:
'Delete_Temp_Ta bles' without the quotes.

Hope this helps,

Mark
"john" <jo**@test.comw rote in message
news:eZ******** ************@ca sema.nl...
When leaving the main menu form I want to delete some temporary tables.
The following code on the form's close works: DoCmd.DeleteObj ect acTable,
"tmpEnvelop ". But is it possible to change it so that it deletes all
tables starting with tmp?
Thanks,
john


Sep 2 '06 #2
why would you delete the temp tables entirely? Why not just truncate
them all? or even just put them in an external DB and then delete the
external DB when you're done with it?

Sep 2 '06 #3
"john" <jo**@test.comw rote
When leaving the main menu form I
want to delete some temporary tables.
. . .
But is it possible to change it so that
it deletes all tables starting with tmp?
You can avoid the need for frequent Compact and Repair if you'll define your
temporary Tables in a temporary Database. There's an example at MVP Tony
Toews' site, http://www.granite.ab.ca/accsmstr.htm. Then when you are done,
you unlink, and delete the entire temporary Database.

Larry Linson
Microsoft Access MVP
Sep 2 '06 #4
Thans Mark and others,
Didn't know you could query on table names like that.
john

"Mark Reed" <ma*********@nt lworld.comschre ef in bericht
news:Zq******** *********@newsf e7-win.ntli.net...
How I would do this is to create a new module and paste the following:

'************** Code Start********** *****
Sub Delete_Temp_Tab les()

Dim Rst As DAO.Recordset
Dim StrSql As String

'Create a recordset containing table names beginning with 'TMP'
StrSql = "SELECT MSysObjects.Nam e " & _
"FROM MSysObjects " & _
"WHERE (((MSysObjects. ParentId) = 251658241)) " & _
"GROUP BY MSysObjects.Nam e " & _
"HAVING (((MSysObjects. Name) Like 'tmp*'));"

Set Rst = CurrentDb.OpenR ecordset(StrSql , , dbReadOnly)

With Rst
Do While Not .EOF
DoCmd.DeleteObj ect acTable, !Name
.MoveNext
Loop
End With

Rst.Close
End Sub
'************** Code End************ ***

Then on the 'Unload' event of your main menu form, simply enter:
'Delete_Temp_Ta bles' without the quotes.

Hope this helps,

Mark
"john" <jo**@test.comw rote in message
news:eZ******** ************@ca sema.nl...
>When leaving the main menu form I want to delete some temporary tables.
The following code on the form's close works: DoCmd.DeleteObj ect acTable,
"tmpEnvelop" . But is it possible to change it so that it deletes all
tables starting with tmp?
Thanks,
john



Sep 3 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
16305
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the equivalent to the SQL 'with' using TSQL? If there is not one, what is the TSQL solution to creating a temporary table that is associated with an SQL statement? Examples would be appreciated. Thank you!!
5
16845
by: Rosa | last post by:
Hi, I'm trying to clear the TIF on Windows XP programmatically with the below code. This code works fine on any folder but the TIF. For some reason the atEnd() statements always defaults to true and no files are deleted in the folder. The peculiarity of this issue is that the files/subfolders cannot be seen through the windows explorer either. I can only access/delete them through a command shell. Any ideas?
1
2614
by: Sampath Reddy | last post by:
Hi Everybody, We are using UDB v8.1 I will explain about my Stored procedures which we are executing in UDB AIX box. We have 3 millions(apporox) of data in 22 tables. By applying the business logic through Stored procedures on 22 tables and writing into 3 new tables. We have used all temporary tables except starting 22 tables. The Stored procedures we have used nearly 6 temporary tables to handle the business logic. Finally we are loading...
2
6984
by: Keith Watson | last post by:
Hi, we are currently implementing an application running on DB2 V7 on Z/OS using largely COBOL stored procedures, managed using WLM. Some of these stored procedures declared global temporary tables, which are declared with ON COMMIT DELETE ROWS to perform work on and then return these temporary tables to the client (which is a message driven EJB connecting via DB2 connect). The client reads the data in the result sets, creates some XML...
6
4628
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application restarts and all active sessions are terminated. This error is also described in detail here:...
1
27054
by: Stefan van Roosmalen | last post by:
Hi there, Is there a way to list the TEMPORATY tables? I have tried SHOW TABLES, but this command only list the regular tables. Thank you very much for your answer. Regards, Stefan.
11
2569
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the data. I'm a bit confused about how to go about removing the rows - all the google searches I have done so far seem to assume that the grid view is bound and the programmer wants to delete the data from the original source. Is there any easy way to...
11
3697
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From the mother table, the incentive is calculated datewise for each employee as per his shift duty. In...
5
8851
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT INTEGER,
0
9993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11256
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10946
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9658
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4705
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3303
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.