473,387 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Have Access 2007 create a subfolder with different Id as foldername

19
Hi all
I hope someone can help me. I need to make some reports out of access, and store them on a network share under a specific report ID. This means that once I have the Report Id I want to create the folder with the ID name and later in the flow I want to dump different extracts to that folder.
Is this possible ? and if yes, can you give me advice as to how I do it ?

Have tried the Run Command OutputTo, but that doesnt seem to have the flexibility of creating a folder with different names....

Thanks in advance
Best regards
Ingrid
Apr 8 '08 #1
4 4000
MikeTheBike
639 Expert 512MB
Hi all
I hope someone can help me. I need to make some reports out of access, and store them on a network share under a specific report ID. This means that once I have the Report Id I want to create the folder with the ID name and later in the flow I want to dump different extracts to that folder.
Is this possible ? and if yes, can you give me advice as to how I do it ?

Have tried the Run Command OutputTo, but that doesnt seem to have the flexibility of creating a folder with different names....

Thanks in advance
Best regards
Ingrid
Hi

There two way I know of creating new directories (there may be more?)

1) Use the MkDir strPath command (just type MkDir in the Access help search box)

eg If Dir(strPath, vbDirectory) = "" Then MkDir strPath

2) Use the FileSystemObject
This Object has comprehensive properties/methods for almost everything to do with the computer file system (like it says on the tin!).

You can either set a reference to the 'Microsoft Scripting Runtime' object library (this will give you access to Properties/Methods List as you write code - early binding - best if you are not familiars with the object(s))

Dim fso as FileSystemObject
Dim fsoFolder as Folder
Set fso = new FileSystemObject


OR you can create an object in code ie

Dim fso As Object
Dim fsoFolder as Object
Set fso = CreateObject("Scripting.FileSystemObject")


Then you can use staments like

If Not fso.FolderExists(strPath) Then Set fsoFolder = fso.CreateFolder(strPath)

where strPath is a variable with the required directory path

HTH


MTB
Apr 9 '08 #2
olseni
19
Hi MiketheBike
Thanks a lot for your answer. However I am not really a coder so I hope you can help me a bit more. I tried searching Access Help with MdDir but nothing came up....
So if I go for option 1, which seams far the easiest, how would I tell Access what to name the folder ? I need to do this on the fly, ie when a textstring is created in my Access application ie R-07-234A....
Sorry if my questions are very basic, but I usually only work in the Access functionality, so going into VBA is a bit difficult for me.... :-(
Thanks
Best regards
Ingrid
Apr 9 '08 #3
MikeTheBike
639 Expert 512MB
Hi MiketheBike
Thanks a lot for your answer. However I am not really a coder so I hope you can help me a bit more. I tried searching Access Help with MdDir but nothing came up....
So if I go for option 1, which seams far the easiest, how would I tell Access what to name the folder ? I need to do this on the fly, ie when a textstring is created in my Access application ie R-07-234A....
Sorry if my questions are very basic, but I usually only work in the Access functionality, so going into VBA is a bit difficult for me.... :-(
Thanks
Best regards
Ingrid
Hi again

Well it's actually MkDir (not MdDir !).

You should jump in and get your feet wet and try thing, it's the only way to learn!

The following code will constict a new Directory (folder) stucture unter the folder with the MDB file that is running the code.

It consists of a sub procedure that takes the path you want to constuct, "splits" it in to an array containing all the individual folder names and then puts them back together one by one and, if it does not exist, creates each one in turn. This approach is necessary as MkDir will only "Make" a directory one level at a time.

Expand|Select|Wrap|Line Numbers
  1. Sub TEST()
  2.     Dim NewDirectory As String
  3.  
  4.     NewDirectory = CurrentProject.Path & "\New Folder\New Sub Folder"
  5.  
  6.     CreateDirectory NewDirectory
  7. End Sub
  8.  
  9. Sub CreateDirectory(ByVal strPath As String)
  10.     Dim Folders() As String
  11.     Dim ThisFolder As String
  12.     Dim i As Integer
  13.  
  14.     Folders = Split(strPath, "\")
  15.  
  16.     For i = 1 To UBound(Folders)
  17.         If i = 0 Then
  18.             ThisFolder = Folders(i)
  19.         Else
  20.             ThisFolder = ThisFolder & "\" & Folders(i)
  21.         End If
  22.         If Dir(ThisFolder, vbDirectory) = "" Then MkDir ThisFolder
  23.     Next i
  24. End Sub
Hope that makes some sense, but copy the code, paste it in to a code module (not a form), put the cursor in the TEST sub and press F5, and see what happens.

If you need more info on 'Split' etc. try Access Help first, then try the forum again.


Best of luck!


MTB
Apr 10 '08 #4
olseni
19
Hi MTB
Thanks a lot, I will try your code.

And sorry abiut the MdDir typo, I did actually search on MkDir and nothing comes out (just tried it again), but maybe there are different help files levels and I only have the standard one that came with Office and not a developer one (if such a thing exists).

Anyway, thanks, I will try and see if I can get this thing going....
Best regards
Ingrid
Apr 14 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Lauren Wilson | last post by:
Hi folks, Can someone point me to some resources on how to control FTP sessions from and Access application with VBA? Many thanks for all help. --LW.
2
by: Eric | last post by:
I am trying to build an app where the stuff in the root directory is open to all, but anything under the Restricted directory requires you to login and I want to use Forms to do it. I'm having...
4
by: Rachel | last post by:
I have tried: System.IO.File.Create("C:\FolderName") It does not create a folder. Any ideas without using the File System Object? Rachel
5
by: Colleyville Alan | last post by:
I have an Access app which uses Office Automation to manipulate and then save PowerPoint files to disk. It works fine, but I need to update the code and I am having problems with the syntax. ...
5
by: Ira Solomon | last post by:
Hi: Any quick opinions on Access 2007? Has anyone got this to coexist with Access 2003? Thanks Ira
5
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big...
2
by: destinman via AccessMonster.com | last post by:
Is it possible or feasible to load one version of Access (2003) and the new version (2007) on the same hard drive and run appliecations on each one separately ? If you can, how do you load the new...
5
by: ISUTri | last post by:
We are currently converting from Access 2003 to Access 2007. I have an Access app that is going to be very difficult to convert. This App is used by people that are out in the field and are a...
1
by: BL3WC | last post by:
Hi, I'd created a MDE under Access 2003. It is now under testing stage. Some of the users will use Access 2003 runtime and some will use Access 2007 runtime to run this MDE. I installed the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.