Inserting a New Column into a Table using a Macro or VBA

G

Guest

I have several queries that create tables that I then use for reporting
purposes. I need to be able to create a Date/Time field in these new created
tables. These tables are constantly replaced so I need to be able to use a
macro or vba to add the new column, name it and set the data type. I can't
find a way to do this using RunCommand or DoMenuItem.

Any Suggestions?
 
R

RoyVidar

Crystal said:
I have several queries that create tables that I then use for
reporting purposes. I need to be able to create a Date/Time field
in these new created tables. These tables are constantly replaced
so I need to be able to use a macro or vba to add the new column,
name it and set the data type. I can't find a way to do this using
RunCommand or DoMenuItem.

Any Suggestions?

You could use a query:

ALTER TABLE myTable ADD COLUMN myDate DateTime

This you could fire off probably through a macro, or by VBA. For VBA,
for instance

CurrentDB.Execute "ALTER TABLE myTable ADD COLUMN myDate DateTime", _
dbFailOnError
 
G

Guest

Thanks, I'll try that. I'm used to SQL but just didn't think of using it for
Access.
 

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