Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 3rd, 2003, 11:45 PM
michael michael is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Sydney, Australia
Posts: 12 michael User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 4 m 33 sec
Reputation Power: 0
Deleting a temporary table

I have a form which contains pushbuttons to run reports. One of the reports is based on multiple queries which create and update a temporary table, and then the temporary table is used to create the report.

I want to delete the temporary table either when the report preview window is closed, or if this is not possible, when the "Return to Main Menu" push button is pressed.

What is the best way to check if this temporary table exists, before I try to delete it, as I currently get an error if the table does not already exist.

Reply With Quote
  #2  
Old December 4th, 2003, 11:12 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
Recogonize that every time you run the update query, it will automatically recreates the table. However I do have code to help you with your problem, but it is at home in another project and when I get there I send it to you, if you still want it.
S-

Reply With Quote
  #3  
Old December 4th, 2003, 04:06 PM
TBÁrpi's Avatar
TBÁrpi TBÁrpi is offline
Lazy User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Hungary, Europe
Posts: 337 TBÁrpi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 5 m 5 sec
Reputation Power: 5
Send a message via MSN to TBÁrpi Send a message via Yahoo to TBÁrpi Send a message via Skype to TBÁrpi
Hi Guys,

Update query does not recreate a table, only a MAKE-TABLE query does it.

Insert, update and delete queries do not delete a table, they're just for modifying data in them.

If the query that creates the records under the report is a make-table query, then it deletes the table having the same name as the query's target.

If SetWarnings=False, then it will NOT prompt you for confirmation before deleting an existing table. It just deletes it w/o any warnings.

If SetWarnings=True, then it will prompt for confirmation.

Application.SetWarnings property can be set from VB code.

To eliminate the run-time error you need to have an error handler code in the sub where the error occurs:
'****************
Sub Whatever

On Error Goto MyErr

' your code here

MyExit:
Exit Sub

MyErr:
MsgBox Err.Number & ", " & Err.Description
Resume MyExit

End Sub
'****************
When you run the code you will get the error number for 'Object not found'. Note the number, and modify the MyErr label to:
'****************
MyErr:
If Err.Number=[the_number_you_noted] Then
Resume Next
Else
MsgBox Err.Number & ", " & Err.Description
Resume MyExit
End If
'****************
__________________
BRegs,
TBÁrpi
"I can only show you the door. You're the one who has to walk through it."

Last edited by TBÁrpi : December 4th, 2003 at 04:15 PM.

Reply With Quote
  #4  
Old December 4th, 2003, 04:14 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
TBÁrpi is right, I mistakenly said update when I meant Make-Table

S-

Reply With Quote
  #5  
Old December 4th, 2003, 06:20 PM
michael michael is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Sydney, Australia
Posts: 12 michael User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 4 m 33 sec
Reputation Power: 0
Thanks for your replies. I already had the code recommended by TBÁrpi in my database.

I have since worked out a way around my problem. I created a Public variable which is of type Boolean, and I set this to true after I have run my make-table query. I check this variable is set to true in the code for the pushbutton that closes the form, and if it is, I execute a DeleteObject command to delete the temporary table.

Regards,

Michael.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Deleting a temporary table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway