Check if an external file exists

W

Wayne-I-M

Hi

I have a form/reports showing photos of clients (for ski lift passes). I
also have a check box showing if the photo has been recieved.

The photos are in a folder on the server.

table = ID Name address etc etc
The photos are called the same as the ID

So person with an ID of 123 has a photo called 123.jpg - 456 has 456.jpg - etc

P:\ski_2009_photos\123.jpg

This all works fine.

Question is it possible to "check" the box if the file exists in the
external folder

So if I load in a photo 789.jpg for person 789 then the PhotoRecieved check
box is updated in record ID789 - I can do the updating bit its just the
referencing to (possibly) non-existant files that I'm have problems with.
Any ideas??

Thank you
 
T

TopJB

Hi

You can use method FileExists

Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("[Path to file]") Then
MsgBox "ok"
Else
MsgBox "not ok"
End If


Wayne-I-M a écrit :
 
W

Wayne-I-M

Many thanks to you both - did a mix-n-match (bit of both answers) and it
works fine


Private Sub butPhotoChecker_Click()
If Dir("P:\ski_2009_photos\" & [CDClientID] & ".jpg") <> "" Then
Me.qryBookings!PhotoReceived = -1
DoCmd.OpenQuery "qryUpdatePhotoRecieved", acViewNormal, acEdit
Else
MsgBox "Photo does not exist"
End If
End Sub

Thanks again

--
Wayne
Manchester, England.



Steve Schapel said:
Wayne,

Test for:
Len(Dir("P:\ski_2009_photos\" & [ID] & ".jpg"))

--
Steve Schapel, Microsoft Access MVP

Wayne-I-M said:
Hi

I have a form/reports showing photos of clients (for ski lift passes). I
also have a check box showing if the photo has been recieved.

The photos are in a folder on the server.

table = ID Name address etc etc
The photos are called the same as the ID

So person with an ID of 123 has a photo called 123.jpg - 456 has 456.jpg - etc

P:\ski_2009_photos\123.jpg

This all works fine.

Question is it possible to "check" the box if the file exists in the
external folder

So if I load in a photo 789.jpg for person 789 then the PhotoRecieved check
box is updated in record ID789 - I can do the updating bit its just the
referencing to (possibly) non-existant files that I'm have problems with.
Any ideas??

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top