We help IT Professionals succeed at work.

image picture path error

buzzcarter
buzzcarter asked
on
Medium Priority
269 Views
Last Modified: 2012-05-06
I have a sub form that contain an image control. The path of the image with change with program installations.  The problem Is how can I trap the error that says the path is not found.

When the form is opened I get a msgbox that conatins, "NameOfMyProgram can't open the file C:\somepath".  And this repeats twice before the form is loaded.

I have tried setting the path via Form_Load but I still get the error.  The image does display.
Break on all errors is selected in Error Trapping

How can I trap this error or set the image path correctly?
Private Sub Form_Load()
Forms!Options![TripSheetSelector_Sub].Form.TripSheetThumb1.Picture = CurrentProject.Path & "\Samples\tripsheet1_thumb.jpg"
 
End Sub

Open in new window

Comment
Watch Question

Commented:
I don't know how to trap the error.

Maybe give this a try:

Change the image to an embedded graphic that will act like a placeholder and permit the form to load successfully.  In the On Load event, then switch to the dynamic path:

Me.YOURIMAGE.Picture= CurrentProject.Path & "\Samples\tripsheet1_thumb.jpg"
Me.YOURIMAGE.PictureType = 1            'change linked image

 



 

Author

Commented:
No that did not work dgmg.  Still have the same error message.
Commented:
I'm thinking you still have a runtime reference to the invalid path.  When you change the image reference to "embedded", then the reference gets resolved at design time and the graphic becomes embedded in your .mdb file and should not produce a runtime error.

Since you get the error message more than one time, I'm thinking you still must have not cleaned up all of the image references.   Convert the form to use all embedded graphics first, with no errors, and it should port from machine to machine just fine.  Then if you want to "externalize" the graphic to a different path on different machines, change it to a linked picture with the correct path during the on load event.





Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Your were correct.  Thank You.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.