Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to create a macro TransferDatabase
where it takes ex. Atbl_2006 and creates Atbl_2007
I would like it to do it Atbl_"yyyy"(now)
create Atbl_"YYYY"(now()+1)
I don't know the appropriate syntax for this
Can this be done, if so how

Thanks
Lizzie
 
I would like to create a macro TransferDatabase
where it takes ex. Atbl_2006 and creates Atbl_2007
I would like it to do it Atbl_"yyyy"(now)
create Atbl_"YYYY"(now()+1)
I don't know the appropriate syntax for this
Can this be done, if so how

The first question I'd ask is - "SHOULD this be done!?"

I'd say No, it should NOT. Storing data (a date, a year) in a
tablename is *extremely bad design*. You're almost always better off
keeping all your data in one table, and using a Query to select the
subset of records for one year.

But if you really want to do this, I believe you'll need to use VBA
code rather than the very limited Access Macros. You would be able to
construct the table name in code with an expression like

Dim strTblName As String

strTblName = "Atbl_" & Format(Date(), "yyyy")

and use that variable in the TransferDatabase method statement.

John W. Vinson[MVP]
 
Back
Top