Execute Make-Tabale query Error Message

ashley25

Registered User.
Local time
Today, 07:11
Joined
Feb 17, 2013
Messages
46
I am trying to execute a make-table query through VBA, however, an error message keeps appearing saying table already exists.

However, if I execute the query manually, it runs normal.

Can someone help?
 
Hi

A few questions.
What is your method of execution? Literallly one of the Execute methods?
(You'll find UI like execution with a DoCmd.OpenQuery instead - though you must also hush warning messages.)
Not that I'm advocating them as a preference. You can delete the table first in code before calling the execute method. For example:
CurrentDb.Execute "DROP TABLE TableName"

Why are you executing a maketable in code in the first place?
A common reason is as a work table, merge source etc.
It's very common that there's no need for a maketable in such circumstances. Running it once during development creates it - thereafter merely emptying it an appending rows back in is all you need. (And helps with user locks placed upon the table which can prevent its deletion entirely.)

Cheers.
 
I've adjusted my code to DoCmd.OpenQuery and this works fine, thanks.

I have noticed now that when the new tables are created they are stored outside of their original Custom group. Is there a way to fix this?
 
You'd have to assign the goup in code - which is no as trivial.
There's a thread here (started by an absolutely charming member) on that subject.
http://www.access-programmers.co.uk/forums/showthread.php?t=215544

Everything Brent has to say I agree with. The concept of a Maketable and then customising groups - sounds like you're providing these as part of a finished app. They're more commonly development time functionalities.

See what you think anyway.
 
I have a lot of tables and queries etc, so I wanted to customise as much as possible to make things easier to me. This tool wont be used by "outsiders".

I will plug away by using the thread, but it seems a little trickier than I expected.
 
Indeed. Can't beat a good set of naming conventions. ;-)
 

Users who are viewing this thread

Back
Top Bottom