Rename a table with a dynamic date in name

ericaann

New Member
Joined
Nov 16, 2005
Messages
4
Is there a way to have a make table add today's date to the actual file name using a macro specifically?

I have a make table query that generates a table called "Permissions", in order to keep historical records (I need individual files) I have to go in and rename yesterday's ON HAND table to ON HAND 10-15, then run the make table query, so all my other queries reference the current ON HAND table.

What I would like to do is run a macro that would rename Permissions to Permissions 10-15 (today's date) and then run the make table that would create today's Permissions table.

Does that make sense?

Thanks,
Erica-ann
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Dynamic Date

Erica-Ann,

I made Macro1 in Access
First line was a Rename command
Second line was an Openquery command

Then I converted the macro to VBA code (Tools/Macro)
Then I added the Date = Now() reference
The final code is below, hope it helps
Sam

Function Macro1()
On Error GoTo Macro1_Err

Date = Now()
DoCmd.Rename "Permissions " & Date, acTable, "Permissions"
DoCmd.OpenQuery "Make Table Query", acNormal, acEdit


Macro1_Exit:
Exit Function

Macro1_Err:
MsgBox Error$
Resume Macro1_Exit

End Function
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top