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

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
Back
Top