select into with dynamic table

boilergal

New Member
Joined
Nov 13, 2015
Messages
2
Is it possible to create a select into statement with the into table being dynamic? I want the table name to be the last day of the previous month.

Here is what I am trying to do.
SELECT table.* INTO format(DateSerial(Year(Date()),Month(Date()),0),'yyyymmdd')
FROM table
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the Board!

It is possible to do with VBA, but first you must ask yourself if it is really necessary. Seldom do you need to have two copies of the same database.
Can you explain why this is necessary? We may have other suggestions for you that may work better.
 
Upvote 0
I was afraid of that. Thanks for the quick response. The table is deleted and recreated every month which is why we make a copy of it. If it not our data so Access was the route decided to create the monthly backups.
 
Upvote 0
So, are you saying that you have a whole bunch of tables, one for each month in your database?
If so, that is probably not the most efficient structure.

What you probably want is one single table that you write your data to each month (so you are constantly adding to a single table, instead of creating new tables). If you do not already have some sort of date identifier, you could add a new field to your table that captures what month the data is for.

Then you could use a static Append Query to write your data to the table, and then an Update Query to update the date field (if you are doing this every month, it should be pretty easy - you would just be updating the records that have a blank in this field after you run your Append Query).

Does that sound like something that might work better for you?
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,252
Members
451,757
Latest member
iours

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