473,804 Members | 3,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check if table exits before delete query

365 Contributor
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 2642
jaxjagfan
254 Recognized Expert Contributor
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
6461
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 results below, I would think that the delete should have deleted row 1 {1 5 me) and not row 3 (1 5 they) when I run this statement delete t1 from t, t1 where t.id = t1.id and t.id=1 and t.name = 'me'; Any ideas on why row 2 is deleted?
2
4993
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 fields (vehicleID, BattID, and ChgHrs). VehicleID and BattID are a TEXT datatype and ChrHrs are a number(long int.) datatype. Since records to be imported can have duplicate records of the composite key I need to clean all but one of the...
2
1594
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 tab structure with fields for various features a phone might have; there are almost 100 of these features to choose from. Rather than a simple check box, I used a combo box with the a value list of "Y, N, N/A, and ?"; I even simplified entry by...
2
8615
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, they have no default value, and their Display Control is Check Box. When I run my make table query, the new fields have a Yes/No Data Type, but the field property format comes up blank, and the Display Control comes up as Text Box. How come...
2
3443
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 effect of if it doesn't exist then create it. (did this be finding the error number). Unfortunately I've moved on since then and I only know it doesn't exist when the form using it is opened! I've then gone past me procedure. It would be anyway far...
8
25083
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 different table. While I am using the tools in Access for query setup, its easier to show it on here using the SQL for the query, which is as follows( the table is ): DELETE .date, .,
5
3088
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 called tblimport exists. If this table exists then I need to delete it. I have tried looking through the web but I can not find a simple solution to this. I do not want a separate module, just a couple lines of code. Does the table exist, Yes =...
5
2589
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 orders in all batches ever submitted by that affiliate. I'm trying to figure out the most efficient way to check the uniqueness of the order ID. Order data is being submitted to Zen Cart, and also stored in custom tables. I have created a unique...
8
3911
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 using php and jquery through a mysql database will not empty the td elements. There is a table underneath the button in the initial html. if you click on a box in the table, it will empty. the same does not happen for the table that is generated by...
0
9704
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
10319
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
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
10070
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
9132
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...
1
7608
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4282
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
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.