From: Isissoft on
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
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
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
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
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.
>
>