473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

delete all the records in the temporary tables automatically

mseo
181 100+
hi,
I have a form that fills the temporary table in some conditions, so, is there any way to delete all the records in that temporary table dynamically (using functions or on an action

appreciate any suggestions
thank you
Jun 13 '10 #1

✓ answered by MMcCarthy

@mseo
You need to run the sql each time ...

Expand|Select|Wrap|Line Numbers
  1. Dim ssql As String 
  2.  
  3.     DoCmd.SetWarnings False 
  4.  
  5.     ssql = "DELETE * FROM tbl_OrderTEMP"
  6.     DoCmd.RunSQL ssql
  7.  
  8.     ssql = "DELETE * FROM tbl_OrderDetailTEMP" 
  9.     DoCmd.RunSQL ssql
  10.  
  11.     DoCmd.SetWarnings True 

10 3016
MMcCarthy
14,534 Expert Mod 8TB
The following statement should work ...

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "DELETE FROM TableName"
Jun 13 '10 #2
jimatqsi
1,271 Expert 1GB
You could put this in the forms close event, supplying the correct table name

Expand|Select|Wrap|Line Numbers
  1. dim strSQL as string
  2. strSQL = "Delete * from tablename"
  3. docmd.RunSQL strSQL
  4.  
Jim
Jun 13 '10 #3
jimatqsi
1,271 Expert 1GB
Mary, looks like we're on the same wavelength :)
Jun 13 '10 #4
MMcCarthy
14,534 Expert Mod 8TB
@jimatqsi
LOL, great minds and all that!
Jun 13 '10 #5
mseo
181 100+
thank you
Expand|Select|Wrap|Line Numbers
  1. dim ssql As String
  2.     DoCmd.SetWarnings False
  3.                  ssql = "DELETE * FROM tbl_OrderTEMP"
  4.                  ssql = "DELETE * FROM tbl_OrderDetailTEMP"
  5.                  DoCmd.RunSQL ssql
  6.     DoCmd.SetWarnings True
just one table gets deleted and this table is the first declared table
when I tried to declare another variable to excute the delete of the other table the same result
any suggestion
Jun 14 '10 #6
MMcCarthy
14,534 Expert Mod 8TB
@mseo
You need to run the sql each time ...

Expand|Select|Wrap|Line Numbers
  1. Dim ssql As String 
  2.  
  3.     DoCmd.SetWarnings False 
  4.  
  5.     ssql = "DELETE * FROM tbl_OrderTEMP"
  6.     DoCmd.RunSQL ssql
  7.  
  8.     ssql = "DELETE * FROM tbl_OrderDetailTEMP" 
  9.     DoCmd.RunSQL ssql
  10.  
  11.     DoCmd.SetWarnings True 
Jun 14 '10 #7
mseo
181 100+
@msquared
thank you
it works fine
I just need to know, if I can Create temp table using vba and after insert the data into it replace the delete line with drop code
I just need to know if it could be done or not
appreciate your help
Jun 14 '10 #8
MMcCarthy
14,534 Expert Mod 8TB
@mseo
If you are asking me if you can do this ...

Expand|Select|Wrap|Line Numbers
  1.     DoCmd.RunSQL "DROP TABLE tbl_OrderTEMP;"
Then the answer is yes :)
Jun 14 '10 #9
mseo
181 100+
@msquared
thank you again and over again
could be more than one table, if so
the steps would be like:
1- create the temp tables
2- insert data in the base tables or temp tables
3- drop the temp tables
Jun 14 '10 #10
MMcCarthy
14,534 Expert Mod 8TB
More or less, there are various different approaches to take from SQL as we've used here to setting up VBA objects using TableDefs. The approach to take depends on what you are doing at the time.
Jun 14 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Peter Gorelczenko | last post by:
I'm running as normal user (not root or database owner). This user has c= reate=20 temporary table priv. show tables partial: GRANT CREATE TEMPORARY TABLES ON `foobar0`.* TO 'foo'@'localhost'...
0
by: Soefara | last post by:
Dear Sirs, I have been developing an application on Windows with MySQL 3.23, making use of temporary tables. Now when I try to port the application to a Unix box running also MySQL 3.23, I...
2
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...
2
by: Chuck Crews | last post by:
I am interested in declaring a global temporary table within an application. The application processes 1 set of 600 or less rows each iteration. Multiple programs can and do call this one...
6
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from...
5
by: Randy Harris | last post by:
An application that I develop uses a lot of temporary tables. I very frequently empty the tables (using DELETE From), then fill them back up. Anyone have comments on what effects I might expect to...
1
by: Sumanth | last post by:
the pseudo code for my update is for i = 1 to n; insert k records into temp_table; update a set c1 = (select c1 from temp_table where temp_table.pk = a.pk), c2 = (...
4
by: john | last post by:
When leaving the main menu form I want to delete some temporary tables. The following code on the form's close works: DoCmd.DeleteObject acTable, "tmpEnvelop". But is it possible to change it so...
2
by: Jim Devenish | last post by:
I have two tables: Deliveries and Invoices. An Invoice can relate to a number of Deliveries. The relevant fields are: Invoices: InvoiceID InvoiceDate Deliveries: DeliveryID
2
by: lieufirst | last post by:
hi there, well i have a db that is consists of 6 tables. 1 for the detailed information of students, 1 for the exams they should take another table that combine student name and class and id from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.