Does anyone know if it is possible to use conditional formatting on fields in a form using the Dir () function if a file exists. And if so how?
Here's my idea: I currently have a sub form with a field that links to files in a folder "Site Reviews". In this field the user types in the date they performed the site review. They are also supposed to put the review letter in the related contractor's folder but that doesn't always happen. So I have it that if you double click on that field Access will run through code building up a filepath (program, contractor, site review folder, then finally the file named with the date of the selected record). If it exists it will open the file, if it doesn't, it will give a message box that the file does not exist, (FYI it will also message out on any step of building the hyperlink (i.e., program folder doesn't exist, contractor folder doesn't exists etc.....)
I used the Dir () function: If Dir(StrFile, vbDirectory) <> vbNullString Then do something, and it works beautifully on the double click event.
But I would like the dates to be conditionally formatted red if the file does not exist and not need to double click the hyperlink to find out. This way I would know that they were missing visually without doing anything. So I tried using the Dir(StrFile, vbDirectory) <> vbNullString with conditional formatting (without the If) and got squat (Tried a few other variations <> "", Len(Dir() etc....nothing...
I then was reading some posts about making another textbox with the control source set to Dir(StrFile, vbDirectory) <> vbNullString etc. so I could give it a 1 or 0 and use that to conditionally format the other field but then I get the #Name? error...
Any ideas? thoughts? Sorry for the long winded post. just wanted to give everyone the picture of what I was trying to accomplish.
As always thank you kindly,
Poz
Here's my idea: I currently have a sub form with a field that links to files in a folder "Site Reviews". In this field the user types in the date they performed the site review. They are also supposed to put the review letter in the related contractor's folder but that doesn't always happen. So I have it that if you double click on that field Access will run through code building up a filepath (program, contractor, site review folder, then finally the file named with the date of the selected record). If it exists it will open the file, if it doesn't, it will give a message box that the file does not exist, (FYI it will also message out on any step of building the hyperlink (i.e., program folder doesn't exist, contractor folder doesn't exists etc.....)
I used the Dir () function: If Dir(StrFile, vbDirectory) <> vbNullString Then do something, and it works beautifully on the double click event.
But I would like the dates to be conditionally formatted red if the file does not exist and not need to double click the hyperlink to find out. This way I would know that they were missing visually without doing anything. So I tried using the Dir(StrFile, vbDirectory) <> vbNullString with conditional formatting (without the If) and got squat (Tried a few other variations <> "", Len(Dir() etc....nothing...
I then was reading some posts about making another textbox with the control source set to Dir(StrFile, vbDirectory) <> vbNullString etc. so I could give it a 1 or 0 and use that to conditionally format the other field but then I get the #Name? error...
Any ideas? thoughts? Sorry for the long winded post. just wanted to give everyone the picture of what I was trying to accomplish.
As always thank you kindly,
Poz