473,378 Members | 1,360 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,378 software developers and data experts.

Check if table exits before delete query

365 100+
Hello, me again

i am creating tables (and deleting them) based on the Public variable StaffID the reason for this is the information used in these tables is used to display staffing information and needs to be viewable on multiple terminals, so i am creating the tables with " & LogStaffID & " infront of the table/query name, but as to not clutter up the database i am deleting the tables on unload of the form, but to avoid errors i wonder if there is an if command i could use to check the table exist

such as

if "" & LogStaffID & "TableName" exists then do delete query

do create query

thanks if ya can help
Jan 2 '08 #1
1 2608
jaxjagfan
254 Expert 100+
Hello, me again

i am creating tables (and deleting them) based on the Public variable StaffID the reason for this is the information used in these tables is used to display staffing information and needs to be viewable on multiple terminals, so i am creating the tables with " & LogStaffID & " infront of the table/query name, but as to not clutter up the database i am deleting the tables on unload of the form, but to avoid errors i wonder if there is an if command i could use to check the table exist

such as

if "" & LogStaffID & "TableName" exists then do delete query

do create query

thanks if ya can help
Here is a function I used for cleaning up import error tables and should work for you as well. Attach the CleanErrors on the form Unload event.

Expand|Select|Wrap|Line Numbers
  1. Public Function CleanErrors()
  2.  
  3. Dim tname As TableDef
  4. Dim db As Database
  5. Dim tdef As TableDefs
  6. On Error Resume Next
  7. Set db = DBEngine(0)(0)
  8. Set tdef = db.TableDefs
  9.  
  10. For Each tname In tdef
  11.     If tname.Name Like "*" & LogStaffID & *" Then
  12.     DoCmd.DeleteObject acTable, tname.Name
  13.     End If
  14. Next
  15.  
  16. End Function
  17.  
Jan 2 '08 #2

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

Similar topics

0
by: Gordon | last post by:
I have 2 tables t and t1. In this case, t1 is a copy of t. I want to delete rows from t1 based on criteria on the t table and a relationship between t ad t1 (in this case the id column). In the...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
2
by: Chris Windsor | last post by:
I hope the following describe what I'm trying to do: I have created a tool to be used by product analysts when studying different cell phone designs. Part of the tool is a set of 11 forms on a...
2
by: Kathy Krizl | last post by:
I'm probably doing something stupid, but I have a make table query. One of the tables I reference has some check box fields in it. Their Data Type is Yes/No, their field property format is Yes/No,...
2
by: John M | last post by:
Hi, I want to create a link to another database table. I've succeeded in doing this, and avoided creating the the link over and over again by putting in the error statement something to the...
8
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
5
by: Mike Charney | last post by:
I have an Access data project. In this project I have a form that when Access starts is loaded and this form has VBA code attached to it. One of the first things I need to do is check if a table...
5
by: Alan Little | last post by:
I have affiliates submitting batches of anywhere from 10 to several hundred orders. Each order in the batch must include an order ID, originated by the affiliate, which must be unique across all...
8
by: thatcollegeguy | last post by:
http://smarterfootball.com/exits/theHTML.html I am not sure what is wrong w/ this code. The main issue is that the table that is in the initial html will empty its td but the table that I load...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.