|
 |
access thread: Finding if a File Exists
Message #1 by "enZo :-\)" <enzaux@g...> on Wed, 19 Jun 2002 10:36:12 +0800
|
|
Hi hello is there any command where in I can check if a file exists on a particular folder. It's kinda weird coz I'm using
IsMissing which I saw in another author's code but It is not working. As I type IsMissing the syntax is shown
"IsMissing(Argument)" so i tried this:
MsgBox IsMissing("C:\test.txt")
Wherein test.txt doesnt exist but the message box results say False. Is "IsMissing" a valid function in Access?
Thanks,
Enzo
Message #2 by "Leo Scott" <leoscott@c...> on Tue, 18 Jun 2002 20:22:32 -0700
|
|
Dim strFile as string
strFile = Dir("C:\test.txt")
look Dir up in the help. There is a lot more it can do.
|-----Original Message-----
|From: enZo :-) [mailto:enzaux@g...]
|Sent: Tuesday, June 18, 2002 7:36 PM
|To: Access
|Subject: [access] Finding if a File Exists
|
|
|
| Hi hello is there any command where in I can check if a
|file exists on a particular folder. It's kinda weird coz I'm using
|IsMissing which I saw in another author's code but It is not
|working. As I type IsMissing the syntax is shown
|"IsMissing(Argument)" so i tried this:
|
| MsgBox IsMissing("C:\test.txt")
|
| Wherein test.txt doesnt exist but the message box results say
|False. Is "IsMissing" a valid function in Access?
|
|Thanks,
|
|Enzo
|
|
|
|
Message #3 by "enZo :-\)" <enzaux@g...> on Wed, 19 Jun 2002 11:40:42 +0800
|
|
Thanks Leo!! Gosh I almost forgot about that :) Thanks for reminding
Enzo
-----Original Message-----
From: Leo Scott [mailto:leoscott@c...]
Sent: Wednesday, June 19, 2002 11:23 AM
To: Access
Subject: [access] RE: Finding if a File Exists
Dim strFile as string
strFile = Dir("C:\test.txt")
look Dir up in the help. There is a lot more it can do.
|-----Original Message-----
|From: enZo :-) [mailto:enzaux@g...]
|Sent: Tuesday, June 18, 2002 7:36 PM
|To: Access
|Subject: [access] Finding if a File Exists
|
|
|
| Hi hello is there any command where in I can check if a
|file exists on a particular folder. It's kinda weird coz I'm using
|IsMissing which I saw in another author's code but It is not
|working. As I type IsMissing the syntax is shown
|"IsMissing(Argument)" so i tried this:
|
| MsgBox IsMissing("C:\test.txt")
|
| Wherein test.txt doesnt exist but the message box results say
|False. Is "IsMissing" a valid function in Access?
|
|Thanks,
|
|Enzo
|
|
|
|
Message #4 by "Mike" <mike.day@o...> on Wed, 19 Jun 2002 09:30:40
|
|
you could use this;
Private Sub CheckFileExists()
Dim IntCheckFile As Integer
On Error GoTo CheckFileExist_Err
IntCheckFile = FileExists("C:\test.txt")
Select Case IntCheckFile
Case -1
MsgBox "The File is not there! "
End
Case 0
MsgBox "exits but no data"
Case 1
MsgBox "File is there "
End Select
CheckFileExist_Exit:
Exit Sub
CheckFileExist_Err:
MsgBox Error$
Resume CheckFileExist_Exit
End Sub
Function FileExists(strFile As String) As Integer
Dim lSize As Long
On Error GoTo FileExist_Err
lSize = -1
lSize = FileLen(strFile)
If lSize = 0 Then
FileExists = 0
ElseIf lSize > 0 Then
FileExists = 1
Else
FileExists = -1
End If
FileExist_Exit:
Exit Function
FileExist_Err:
MsgBox Error$
Resume FileExist_Exit
End Function
Message #5 by braxis@b... on Wed, 19 Jun 2002 09:47:39 +0100 (BST)
|
|
Enzo
IsMissing is used to find out if an optional, variant parameter has been passed to a function:
Public Function foo(strVar as string,optional varOpt as variant) as boolean
If Not IsMissing(varOpt) then
'run some code using the optional parameter
End If
End Function
Brian
> from: "enZo :-)" <enzaux@g...>
> date: Wed, 19 Jun 2002 03:36:12
> to: access@p...
> subject: Re: [access] Finding if a File Exists
>
>
> Hi hello is there any command where in I can check if a file exists on a particular folder. It's kinda weird coz I'm using
> IsMissing which I saw in another author's code but It is not working. As I type IsMissing the syntax is shown
> "IsMissing(Argument)" so i tried this:
>
> MsgBox IsMissing("C:\test.txt")
>
> Wherein test.txt doesnt exist but the message box results say False. Is "IsMissing" a valid function in Access?
>
> Thanks,
>
> Enzo
>
>
>
Message #6 by "enZo :-\)" <enzaux@g...> on Wed, 19 Jun 2002 16:56:55 +0800
|
|
Mike,
Are you sure there are no missing code for FileExists function? Which Line of the code there that will search for the file if
exist?
Thanks,
Enzo
-----Original Message-----
From: Mike [mailto:mike.day@o...]
Sent: Wednesday, June 19, 2002 9:31 AM
To: Access
Subject: [access] RE: Finding if a File Exists
you could use this;
Private Sub CheckFileExists()
Dim IntCheckFile As Integer
On Error GoTo CheckFileExist_Err
IntCheckFile = FileExists("C:\test.txt")
Select Case IntCheckFile
Case -1
MsgBox "The File is not there! "
End
Case 0
MsgBox "exits but no data"
Case 1
MsgBox "File is there "
End Select
CheckFileExist_Exit:
Exit Sub
CheckFileExist_Err:
MsgBox Error$
Resume CheckFileExist_Exit
End Sub
Function FileExists(strFile As String) As Integer
Dim lSize As Long
On Error GoTo FileExist_Err
lSize = -1
lSize = FileLen(strFile)
If lSize = 0 Then
FileExists = 0
ElseIf lSize > 0 Then
FileExists = 1
Else
FileExists = -1
End If
FileExist_Exit:
Exit Function
FileExist_Err:
MsgBox Error$
Resume FileExist_Exit
End Function
Message #7 by "Mike" <mike.day@o...> on Wed, 19 Jun 2002 11:18:25
|
|
Enzo,
I use this to check if a file is there before i run something.
this code just tests to see if the file has a file size, if the file isn't there it will error,
cheers
Message #8 by "Gerald, Rand" <RGerald@u...> on Wed, 19 Jun 2002 09:38:38 -0500
|
|
The IsMissing function should only be used to detect if an optional
parameter for a subroutine or function is missing or has been filled
in.
Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx
-----Original Message-----
From: enZo :-) [mailto:enzaux@g...]
Sent: Tuesday, June 18, 2002 9:36 PM
To: Access
Subject: [access] Finding if a File Exists
Hi hello is there any command where in I can check if a file
exists
on a particular folder. It's kinda weird coz I'm using
IsMissing which I saw in another author's code but It is not working.
As I
type IsMissing the syntax is shown
"IsMissing(Argument)" so i tried this:
MsgBox IsMissing("C:\test.txt")
Wherein test.txt doesnt exist but the message box results say False.
Is
"IsMissing" a valid function in Access?
Thanks,
Enzo
Message #9 by "enZo :-\)" <enzaux@g...> on Thu, 20 Jun 2002 08:41:43 +0800
|
|
Thanks!!!!! It was the FileLen that made the important part. Sorry I haven't noticed it. Thanks
Enzo
-----Original Message-----
From: Mike [mailto:mike.day@o...]
Sent: Wednesday, June 19, 2002 11:18 AM
To: Access
Subject: [access] RE: Finding if a File Exists
Enzo,
I use this to check if a file is there before i run something.
this code just tests to see if the file has a file size, if the file isn't there it will error,
cheers
|
|
 |