Solved Rename tablewith a week number (1 Viewer)

Number11

Member
Local time
Today, 04:24
Joined
Jan 29, 2020
Messages
607
is it possible to rename a table ending with the current week number it was created and or

export the table via a query ending in the week number it was generated ?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:24
Joined
Oct 29, 2018
Messages
21,473
Almost anything is possible, but why? Also, you export the data, not the table name. So, I'm not sure I understand your second question.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:24
Joined
Feb 28, 2001
Messages
27,185
Generally, you rarely export tables, you export queries. So store the week info in the table, then have the query filter for whatever week you want (but don't include the week ID in the SELECT clause, only in the WHERE clause.)

Renaming tables is possible but tends to break relationships AND/OR require you to rebuild new relationships.
 

Number11

Member
Local time
Today, 04:24
Joined
Jan 29, 2020
Messages
607
Thanks for your pointers, i have now created a new table and have a vbs to rename it adding the current week number, and have also changed my code so when i export the table to excel it names the file with the current week number too so all sorted.

will share code in a bit
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:24
Joined
Feb 19, 2002
Messages
43,275
It is very wrong to create a table in your database for each week.

As Doc suggested, use a query to select data for the specific week from your table. You would use code to concatenate the selected week to the table name in your TransferSpreadsheet method.

Sample code for creating the export file name might look like:

FileName = "YourTableName"& "_" & Me.txtYear & Me.txtWeekNum & ".XLSX"
 

Users who are viewing this thread

Top Bottom