|
From: Isissoft on 6 Jul 2008 09:34 I am trying to output a file from Access - I use the following code to make a folder if it does not already exist; DestFile2="C:\Copy" If Dir(DestFile2) = " " Then ' CHECK IF PATH EXISTS MkDir (DestFile2) ' If NOT - Make IT End If ' End Check Folder Name This does work if the folder does not exist, but fails if it does already - obviously my test is wrong ? Can anyone give me the code to do this ? I have a function that will do the job but I would like to sort this problem for other reasons. Thanks for any help.
From: boblarson on 6 Jul 2008 11:15 I think the part that you are having trouble with is that you have a space between your double quotes and not together: > DestFile2="C:\Copy" > If Dir(DestFile2) = " " Then should be > DestFile2="C:\Copy" > If Dir(DestFile2) = "" Then -- Bob Larson Access MVP Access World Forums Administrator Utter Access VIP Tutorials at http://www.btabdevelopment.com __________________________________ "Isissoft" wrote: > I am trying to output a file from Access - I use the following code to make > a folder if it does not already exist; > DestFile2="C:\Copy" > If Dir(DestFile2) = " " Then ' CHECK IF PATH EXISTS > MkDir (DestFile2) ' If NOT - Make IT > End If ' End Check Folder Name > > This does work if the folder does not exist, but fails if it does already - > obviously my test is wrong ? > > Can anyone give me the code to do this ? > > I have a function that will do the job but I would like to sort this > problem for other reasons. > > Thanks for any help. >
From: Arvin Meyer [MVP] on 6 Jul 2008 11:25 Branching the code and/or error handling should work for you: DestFile2="C:\Copy" If Dir(DestFile2) = " " Then ' CHECK IF PATH EXISTS MkDir (DestFile2) ' If NOT - Make IT Else Exit Sub End If ' End Check Folder Name -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Isissoft" <isissoft(a)NOSPAMonetel.com> wrote in message news:02c6d86e$0$15068$c3e8da3(a)news.astraweb.com... >I am trying to output a file from Access - I use the following code to make > a folder if it does not already exist; > DestFile2="C:\Copy" > If Dir(DestFile2) = " " Then ' CHECK IF PATH EXISTS > MkDir (DestFile2) ' If NOT - Make IT > End If ' End Check Folder Name > > This does work if the folder does not exist, but fails if it does > already - > obviously my test is wrong ? > > Can anyone give me the code to do this ? > > I have a function that will do the job but I would like to sort this > problem for other reasons. > > Thanks for any help.
From: Douglas J. Steele on 6 Jul 2008 12:25 Both Bob and Arvin seem to have forgotten to include the vbDirectory option for the Dir function call: DestFile2="C:\Copy" If Len(Dir(DestFile2, vbDirectory)) = 0 Then ' CHECK IF PATH EXISTS MkDir (DestFile2) ' If NOT - Make IT End If ' End Check Folder Name -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Isissoft" <isissoft(a)NOSPAMonetel.com> wrote in message news:02c6d86e$0$15068$c3e8da3(a)news.astraweb.com... >I am trying to output a file from Access - I use the following code to make > a folder if it does not already exist; > DestFile2="C:\Copy" > If Dir(DestFile2) = " " Then ' CHECK IF PATH EXISTS > MkDir (DestFile2) ' If NOT - Make IT > End If ' End Check Folder Name > > This does work if the folder does not exist, but fails if it does > already - > obviously my test is wrong ? > > Can anyone give me the code to do this ? > > I have a function that will do the job but I would like to sort this > problem for other reasons. > > Thanks for any help.
From: boblarson on 6 Jul 2008 13:07 Doug: You are correct - I was thinking FILE, not FOLDER. :-) -- Bob Larson Access MVP Access World Forums Administrator Utter Access VIP Tutorials at http://www.btabdevelopment.com __________________________________ "Douglas J. Steele" wrote: > Both Bob and Arvin seem to have forgotten to include the vbDirectory option > for the Dir function call: > > DestFile2="C:\Copy" > If Len(Dir(DestFile2, vbDirectory)) = 0 Then ' CHECK IF PATH > EXISTS > MkDir (DestFile2) ' If NOT - Make IT > End If ' End Check Folder Name > > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele > (no e-mails, please!) > > > > "Isissoft" <isissoft(a)NOSPAMonetel.com> wrote in message > news:02c6d86e$0$15068$c3e8da3(a)news.astraweb.com... > >I am trying to output a file from Access - I use the following code to make > > a folder if it does not already exist; > > DestFile2="C:\Copy" > > If Dir(DestFile2) = " " Then ' CHECK IF PATH EXISTS > > MkDir (DestFile2) ' If NOT - Make IT > > End If ' End Check Folder Name > > > > This does work if the folder does not exist, but fails if it does > > already - > > obviously my test is wrong ? > > > > Can anyone give me the code to do this ? > > > > I have a function that will do the job but I would like to sort this > > problem for other reasons. > > > > Thanks for any help. > >
|
Next
|
Last
Pages: 1 2 Prev: New member, can any one help? Next: Which database program is best suited to lots of images? |