Avatar of Seamus2626
Seamus2626
Flag for Ireland asked on

Export with Workday

Hi,

I have a table in Access 2003 called "GL Balances"

I would like to export this on a form to the below location but naming the file with "Balances 03/03/2011" but i would like the date to change each day. So its like excel =WORKDAY(Today(),-1)

Location

G:\Asset Services MI\UnMatched Merit\Balances

Does anyone have the code to achieve this?

Thanks
Seamus
Microsoft Access

Avatar of undefined
Last Comment
Seamus2626

8/22/2022 - Mon
als315

It is impossible to save file with "/" in name.
You can use "_" or "-" or "."
Seamus2626

ASKER
Yeah, theres no need for it to have /, 03032011 is fine

Thanks
Seamus
als315

Dim path As String
path = "G:\Asset Services MI\UnMatched Merit\Balances\Balances "
path = path & Format(Now(), "mm_dd_yyyy.xls")
Then you can use this file name in export command.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Seamus2626

ASKER
Im a code novice, so am womdering where i would put it in the export

I currently export with

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "Balances", "G:\Asset Services MI\UnMatched Merit\Balances.xls", True, "GL Balances"

Thanks
Seamus
Seamus2626

ASKER
Also, that looks like today, is there workday-1 in Access code?

Thanks
Seamus
als315

Dim path As String, D As Date
D = DateDiff("d", Now(), 1)
D = DateValue("05.03.2011")
While Weekday(D) = vbSunday Or Weekday(D) = vbSaturday
    D = DateAdd("d", -1, D)
Wend
path = "G:\Asset Services MI\UnMatched Merit\Balances\Balances "
path = path & Format(D, "mm_dd_yyyy.xls")
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
als315

Remove D = DateValue("05.03.2011") - it was test
ASKER CERTIFIED SOLUTION
als315

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Seamus2626

ASKER
Thanks!

Seamus