Group:  Microsoft Access ยป microsoft.public.access.modulescoding
Thread: How to check if a file exists?

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

How to check if a file exists?
"Brenda" <rld0210REMOVE[ at ]REMOVEgmail.com> 06.03.2006 02:39:49
Hello, (I apologize if this appears twice ... I had a problem when
sending...)

In a VBA module, how can I tell if a file exists before doing the
TransferSpreadsheet? What I would like is something like this:

filename = <calculated from some values on the form>
if filename exists then
ask for alternate file name
endif


Thank you,


Re: How to check if a file exists?
"Allen Browne" <AllenBrowne[ at ]SeeSig.Invalid> 06.03.2006 03:43:11
Use Dir().

Example (without error handling):

Function FileExists(strFile As String) As Boolean
FileExists = (Len(Dir$(strFile)) > 0)
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Brenda" <rld0210REMOVE[ at ]REMOVEgmail.com> wrote in message
news:eHjS%23cMQGHA.3924[ at ]TK2MSFTNGP14.phx.gbl...
[Quoted Text]
> Hello, (I apologize if this appears twice ... I had a problem when
> sending...)
>
> In a VBA module, how can I tell if a file exists before doing the
> TransferSpreadsheet? What I would like is something like this:
>
> filename = <calculated from some values on the form>
> if filename exists then
> ask for alternate file name
> endif


Re: How to check if a file exists?
"Brenda" <rld0210REMOVE[ at ]REMOVEgmail.com> 06.03.2006 11:40:34
Thank you!

....Brenda

"Allen Browne" <AllenBrowne[ at ]SeeSig.Invalid> wrote in message
news:utl7YANQGHA.224[ at ]TK2MSFTNGP10.phx.gbl...
[Quoted Text]
> Use Dir().
>
> Example (without error handling):
>
> Function FileExists(strFile As String) As Boolean
> FileExists = (Len(Dir$(strFile)) > 0)
> End Function
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Brenda" <rld0210REMOVE[ at ]REMOVEgmail.com> wrote in message
> news:eHjS%23cMQGHA.3924[ at ]TK2MSFTNGP14.phx.gbl...
>> Hello, (I apologize if this appears twice ... I had a problem when
>> sending...)
>>
>> In a VBA module, how can I tell if a file exists before doing the
>> TransferSpreadsheet? What I would like is something like this:
>>
>> filename = <calculated from some values on the form>
>> if filename exists then
>> ask for alternate file name
>> endif
>
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net