473,474 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Check to see whether a table exists

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 neater if
I could first check whether it exits and if not create it.

Thanks
Nov 13 '05 #1
2 3426
Error handler is acceptable.

You could examine the TableDefs collection to see if the table is there.

You could test:
IsNull(DLookup("Name", "MSysObjects" _
"(Name = ""Table1"") AND (Type IN (1, 4, 6))"))
where "table1" represents the name of your table.
Type 1 is a local table. 6 is a linked table. 4 is ODBC linked.

A better idea might be to leave the table in place and just empty it instead
of creating and deleting it:
dbEngine(0)(0).Execute "DELETE FROM Table1;", dbFailOnError

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John M" <jo**@jmawer.demon.co.uk> wrote in message
news:ci******************@news.demon.co.uk...
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 neater
if
I could first check whether it exits and if not create it.

Nov 13 '05 #2
I have handled the same situation by enabling "on error resume next",
then deleting the table link, then creating the table link


On Sun, 12 Sep 2004 16:36:14 +0100, "John M" <jo**@jmawer.demon.co.uk>
wrote:
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 neater if
I could first check whether it exits and if not create it.

Thanks

**********************
ja**************@telusTELUS.net
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security
Nov 13 '05 #3

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

Similar topics

2
by: Jonathan | last post by:
I am looking for a simple way to check if a database table exists. I keep getting advice to use "Try.. Catch" and other error handling methods, but I obviously don't want to have to display an...
3
by: DottingTheNet | last post by:
i promise no more silly questions after this but how do i check if a table exists?? it is my understanding that the exists can only be used in the where clause of the query. i just want s'thing...
2
by: adam | last post by:
hello What query shoul I send to SQL serwer ( in transact SQL language ) to check does some database exist on serwer ? It similar to problem "does some table exist in database" - resolve to it...
7
by: andylcx | last post by:
Hi all: The c++ language can check whether the file exist or not. I am wondering how c language does this job? Thanks a lot! Andy
10
by: Geoff Jones | last post by:
Hi I'm trying to drop a table by using: Dim cmd As New OleDbCommand("DROP TABLE IF EXISTS books", myconnection) cmd.ExecuteNonQuery() but I get a syntax error: "Syntax error in DROP TABLE...
14
by: Dan | last post by:
Hello, we have an intranet application using Windows Integrated Authentification. When an user starts the application, he gets a form for inputting data. The first time he does that, the...
3
by: pollygw | last post by:
I have a page that dynamically adds rows to a table and the user can also delete any of the rows in no specific order. When the form is submitted I need to do some validation. I can't loop through...
2
by: sweatha | last post by:
I have created a login form in asp.net web page.Just like that I have created a table named login which has 2 fields as username & password in SQL Server 2000. I have to check whether the...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
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
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,...
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
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.