Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignoring errors in VBA code

Status
Not open for further replies.

volvoman

Technical User
Mar 16, 2004
2
GB
How do I get access to ignore all errors in a localised manner. ie, in a particular piece of code.

I have adapted the code published for displaying pictures in an image box, but some records don't have a picture. How do I stop the cannot find file error, also, how do I display a default picture for all records without a matching file in the directory I am using?
 
Hi Volvoman.

Depends on how you select/assign the picture names.
In code, you could use a FileSystemObject and "FileExists":
Code:
Dim fs
Set fs=CreateObject("Scripting.FileSystemObject")
if not fs.FileExists("full path") then
   me.[control name].Image="C:\Default.jpg"
else
   ...  
Endif

This is just an example, but perhaps it can give you a hint.

Cheers,
Andy

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top