473,403 Members | 2,354 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,403 software developers and data experts.

Check For Table

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 = Delete it, No=Continue code execution.

Does any one know how to do this?

Thanks,
Mike
m charney at dunlap hospital dot org
Apr 17 '06 #1
5 3072
"Mike Charney" <no*****@everything.net> wrote in
news:aO******************@newssvr27.news.prodigy.n et:
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 = Delete it, No=Continue code execution.

Does any one know how to do this?

Thanks,
Mike
m charney at dunlap hospital dot org


I have a one line solution but I guess that's too few.

Besides, 99 times out of 100, it's bad form and/or reflects poor design to
be constantly deleting and creating a table, and I wouldn't want to
propogate bad form or poor design.

What's that, you just asked or a solution and not a lecture? Tant pis!

--
Lyle Fairfield
Apr 17 '06 #2
Lyle Fairfield <ly***********@aim.com> wrote:
: "Mike Charney" <no*****@everything.net> wrote in
: news:aO******************@newssvr27.news.prodigy.n et:

:> 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 = Delete it, No=Continue code execution.
:>
:> Does any one know how to do this?
:>
:> Thanks,
:> Mike
:> m charney at dunlap hospital dot org

: I have a one line solution but I guess that's too few.

: Besides, 99 times out of 100, it's bad form and/or reflects poor design to
: be constantly deleting and creating a table, and I wouldn't want to
: propogate bad form or poor design.

: What's that, you just asked or a solution and not a lecture? Tant pis!

: --
: Lyle Fairfield

Now that you've heard the advice of a master user of Access,
here's something found by a 'fair' user of google:

http://www.fontstuff.com/access/acctut16.htm

gives the one-line of code for deleting a table. I'm sure Lyle
can actually do the whole thing in one line, but *I* would need
to add error-trapping code to handle the error if the table
doesn't exist.
--thelma
Apr 17 '06 #3

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:e2**********@uwm.edu...
Lyle Fairfield <ly***********@aim.com> wrote:
: "Mike Charney" <no*****@everything.net> wrote in
: news:aO******************@newssvr27.news.prodigy.n et:

:> 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 = Delete it, No=Continue code execution.
:>
:> Does any one know how to do this?
:>
:> Thanks,
:> Mike
:> m charney at dunlap hospital dot org

: I have a one line solution but I guess that's too few.

: Besides, 99 times out of 100, it's bad form and/or reflects poor design
to
: be constantly deleting and creating a table, and I wouldn't want to
: propogate bad form or poor design.

: What's that, you just asked or a solution and not a lecture? Tant pis!

: --
: Lyle Fairfield

Now that you've heard the advice of a master user of Access,
here's something found by a 'fair' user of google:

http://www.fontstuff.com/access/acctut16.htm

gives the one-line of code for deleting a table. I'm sure Lyle
can actually do the whole thing in one line, but *I* would need
to add error-trapping code to handle the error if the table
doesn't exist.
--thelma

Thanks Thelma.

I guess Lyle was to busy being an arrogant butt to help.
Apr 17 '06 #4
Mike Charney wrote:
Does the table exist, Yes = Delete it, No=Continue code execution.


Why don't you just simply run the equivalent of a delete query:

Delete * from tblimport

and do your coding based on an empty table?

Not sure how this is done exactly in ADO, but the DAO equivalent, is a
simple

CurrentDb.Execute "delete * from tblimport", dbFailOnError

As Lyle says, it's frankly kind of silly to be deleting and,
presumeably, creating tables in an app this way. Replace your "create
table" type code with an append query.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Apr 17 '06 #5
i want to get public rowid in MS-ACCESS
can anybody know hot to get rowid of table same as in Oracle


if know then tell me plz
Apr 22 '06 #6

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...
2
by: Doug Baroter | last post by:
Hi, DDLs and DMLs: create table #job (jobID int identity(1,1) primary key, jobName varchar(25) unique not null, jobEndDate dateTime, jobComplete bit default(0), check (( is null and = 0) OR (...
3
by: RAD | last post by:
I am working with an evaluation copy of SQL Server 2000 for the first time; my DB experience lies with MS Access. I have a simple table in SQL Server (tblCompany) that has a field called...
5
by: Steve Wylie | last post by:
I am constructing an HTML questionnaire and one of the questions requires people to rate some choices from 1 to 5, where 1 is their favourite and 5 is their least favourite: Car Bus Taxi cab...
9
by: Edmund Dengler | last post by:
Greetings! Just trying some tests out, and wanted to know about some optimizations. If I do a CHECK constraint on a table, is this used to optimize a SELECT or does Postgresql rely mostly on...
3
by: ferg | last post by:
I have a Customer table. The table has two different CHECK constraints. Then there is the Customer details dialog, which provides the user with an UI for changing users. I have some UPDATE sql,...
1
by: huyuhui | last post by:
The following is a question of LOAD utility. Question: How does the DB2 enforce table check constraints for data added to table with the LOAD utility? A. With the BUILD phase of LOAD B. With the...
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...
16
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
5
by: starke1120 | last post by:
Im creating a check in – check out database for RF guns. I have a table that contains models. ID (primary key) Model A table that contains Gun Details ID (primary key) Model_id...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
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
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
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...

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.