Hello,
I would like to have a function or so can check if a given file exists.
Can anyone help please.......
Thanks
vbBoy.
Printable View
Hello,
I would like to have a function or so can check if a given file exists.
Can anyone help please.......
Thanks
vbBoy.
Hi,
You can use this code
Code:Public Function FileExists(Bestand As String) As Boolean
FileExists = (Dir(Bestand) <> "")
End Function
Public Function Run_Update_Quotations()
strSource = "\\Euermw01\Access\SalesDB\Data\Quotations_Data.mdb"
strDestination = "\\Euermw01\Access\SalesDB\Data\Quotations_Backup_" & _
Day(Now()) & "_" & Month(Now()) & "_" & Year(Now()) & ".mdb"
If Not FileExists(strDestination) Then
FileCopy strSource, strDestination
End If
...
End Function
VB Code:
'' Does a given file exist ? Private Function Exists(ByVal strFullPath As String) As Boolean Exists = Len(Dir(strFullPath)) <> 0 End Function
use the Dir() funciton.
usage Dir("filepath")
example:
VB Code:
If Dir("C:\bob.txt") Then 'File exists 'you code here End if
Sorry to say this but your code doesn't work.Quote:
Originally posted by darre1
use the Dir() funciton.
usage Dir("filepath")
example:
VB Code:
If Dir("C:\bob.txt") Then 'File exists 'you code here End if
teeheehee :)
you're quite right.
should be:
VB Code:
If Dir("C:\bob.txt") <> "" Then 'File exists 'you code here End if
bollocksQuote:
Originally posted by plenderj
teeheehee :)
:D
Thats the normal way of doing it, but my approach is actually faster as far as I know.
Comparing numbers is faster than strings you see :)
true.