Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 31st, 2006, 05:30 PM
Authorized User
 
Join Date: May 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Save file location code.

I'm trying to save a excel form (populated from Access)
to another folder.
My regular code is:
'================================
FileStr = fso.getparentfoldername(Access.CurrentDb.Name) & "\Trans" & "-" & CompName & "-" & Draftval & "-" & Format(Date, "mmddyy") & "-" & TIDNo

xlDoc.SaveAs FileStr
'================================
This will save to the current database location.
If modified this to save into a new folder location:
'================================

FileStr = fso.getparentfoldername("N:\TransLog") & "\Trans" & "-" & CompName & "-" & Draftval & "-" & Format(Date, "mmddyy") & "-" & TIDNo
xlDoc.SaveAs FileStr

'==================================
This was to save into the folder "N:\translog"
as the file name listed.
Problem, it is still saving in the original folder location.
Can anyone help with the correct code solution?
Thanks

John Paul
__________________
John Paul
 
Old June 5th, 2006, 03:13 PM
Authorized User
 
Join Date: May 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have found the answer,
Code:
xlDoc.SaveAs ("N:\Forms") & "\Trans" & "-" & TIDNo

I didn't need to use the FSO.getparentfolder in this case.



Thanks

John Paul
 
Old June 9th, 2006, 07:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Great you found the answer. Hey, just a suggestion since I see you're using the date in your file name. Instead of Format(Date, "mmddyy"), consider Format(Date, "yyyymmdd").

1) Is it Y2K compliant (many IT depts. will not accept two-year digits in anything now).

2) When you use File Manager or Windows Explorer and sort by file name, the file names will sort by year, then month, then day properly. In the other way, they'll sort by month then day then year. Not a typically desired sort. You'll end up with all Januarys for X years first, then all Februarys, etc. instead of one year first then by its months and days, then the next year, etc.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
save in location Archangel Word VBA 1 July 13th, 2007 04:09 PM
File Location AlexSepahpour ASP.NET 2.0 Basics 0 March 11th, 2007 12:58 AM
Configuration file name and location TomH VB Databases Basics 2 September 29th, 2006 06:59 PM
sample code "location not fully trusted" swartzbill2000 BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 July 20th, 2005 04:06 AM
Visio Templates for UML Code Generation location Imar General .NET 1 March 6th, 2005 12:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.