creating a table using VB

D

dshemesh

Hello,
is there a way to create a table using vb?
essentially, I want some specific table called tempT to be the rowSource of
a chart. but every time I open the chart I want to erase the table tempT and
re-create it differently using vb, so I actually want to erase an existing
table (or erase all its fields) and then re-define its properties. Is there a
way doing that?
thank you
 
C

Chaim

You write a CREATE TABLE SQL statement and issue it in VB just as you would
any other SQL statement.

Don't forget: SQL is divided into Data Definition and Data Manipulation sets
of commands. But to VB, it's all the same.
 
D

dshemesh

Thanks.
I tried it and it works. the only problem is that every time I get to that
specific line in the code, I get a message that the table already exists and
therefor will be erased before it is re-created, and I need to confirm.
Is there a way erasing it manually to avoid the message?
thanks
 
T

Tim Ferguson

Is there a way erasing it manually to avoid the message?

db.execute "DROP TABLE MyTable", dbFailOnError


Remember to DROP any constraints (e.g. relationships) that involve it
first.

Hope that helps


Tim F
 
P

Paul Overway

Is it really necessary that you delete the table from the database every
time? Is the structure always the same? If yes, you could delete the
existing records instead of the entire table...and then append the new
records.
 
D

dshemesh

Yes it is. The structure and the data verifies...
I found that using the following line works:
DoCmd.deleteObject acTable, "TableName"

Thanks for all the help
 

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