[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

image picture path error

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

0
buzzcarter
Asked:
buzzcarter
  • 2
  • 2
1 Solution
 
dqmqCommented:
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

 



 

0
 
buzzcarterAuthor Commented:
No that did not work dgmg.  Still have the same error message.
0
 
dqmqCommented:
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.





0
 
buzzcarterAuthor Commented:
Your were correct.  Thank You.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now