need help with using of functions

  • Thread starter Cire via AccessMonster.com
  • Start date
C

Cire via AccessMonster.com

Hi all, i searched for code in this forum for checking of existence of table
before deleting, i found the code shown below but i don't know how to use
functions, do i place this code in a module then invoke it in the form i want?
if yes how do i invoke it? i would probably want to put this in my "exit"
command button for my main menu form. And i'm using Access 2003, and if there
are other alternatives please do share too.

Thanks
Eric


Public Function TableExists(strTableName as String) as Boolean

dim tdf as dao.tabledef

TableExists = False

for each tdf in currentdb.tabledefs
if tdf.name = strTableName then
TableExists = True
Exit For
end if
next

End Function
 
C

Cire via AccessMonster.com

TC said:
Why do you want to delete the table?

It is not very usual to do what you're asking.

TC (MVP Access)
http://tc2.atspace.com

well i'm using the tables just to store data from my pass-through queries,
and if the user runs lots of queries and repeats them with different criteria,
the mdb size would increase quite significantly even when i put in an auto-
compact code in the exit application button. Thus this is more of a clean up
procedure. btw i solved this problem by absorbing the "no table object found"
error, it works fine so i guess i'm sticking to it.
 
R

RobFMS

If I understand what you are doing, that is, just reusing the table to store
data temporarily, then this is what I suggest.

1. Create the table once and keep it on the front-end side (if you have
front-end/back-end database setup).

2. Whenever you need to use the table, delete the *contents* (not the table)
first.

3. Process the data in the table according to your business ruls.

If an error occurs trying to clear the contents, then display an appropriate
message to the user and cancel the rest of the processing. There is no
reason to be deleting and recreating the table if you only want to clear out
the contents.

HTH


--
Rob Mastrostefano

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com
 
T

TC

The other alternative to what Rob said, is to *programatically*:

- create a temporary database;
- create the table in that database;
- create a link to that table;
- do your thing, using that link; then
- delete the temporary database.

This sounds like *loads* of work, but it is actually very simple. Some
googling should find some code to do it.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
C

Cire via AccessMonster.com

RobFMS said:
If I understand what you are doing, that is, just reusing the table to store
data temporarily, then this is what I suggest.

1. Create the table once and keep it on the front-end side (if you have
front-end/back-end database setup).

2. Whenever you need to use the table, delete the *contents* (not the table)
first.

3. Process the data in the table according to your business ruls.

If an error occurs trying to clear the contents, then display an appropriate
message to the user and cancel the rest of the processing. There is no
reason to be deleting and recreating the table if you only want to clear out
the contents.

HTH
[quoted text clipped - 13 lines]
found"
error, it works fine so i guess i'm sticking to it.

oh deleting the content, hmm, sounds easier than the other suggestion ;) i
will probably look it up in this forum and test it out. Thanks for your
feedback guys.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top