By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Set Image Control to Null

P: 675
When Access saves a form with a linked image control, It saves the last-used image name in the Picture property.

When I sync my 2 computers, if I have changed code, starting the program on the other computer causes message
Expand|Select|Wrap|Line Numbers
  1. "Microsoft Access can't open the file 'D:\Old image name.jpg'.
This occurs before the Form.Open event.

Can I trap this, or cancel this or change some property of the image control when I save the form so this doesn't happen. I tried to change the visible property, but that didn't work. Error occurs even if control not visible.

This message will occur every time I use the program until I save the form again. That will cause the sync routines to copy the now most recent version to the other machine, and the problem occurs again.

Can I put a stop to this annoyance?
May 9 '09 #1
Share this Question
Share on Google+
5 Replies

Expert 2.5K+
P: 2,653
Hello, OldBirdman.

I couldn't reproduce that. In my case it didn't use last linked picture file and didn't ask to save form on closing after Picture property if Image control was modified via code.

May 10 '09 #2

P: 675
Thanks Fish. So if you open the form in design view, what are the property values for imgCtl.Picture and imgCtl.PictureType?

As soon as I create an Image Control, Access asks for an Image name. If I don't enter a name in the dialog, the control is removed.

Now there is a name in imgCtl.Picture. It is C:\Pictures\TestImage.jpg and this name persists when I change Picture type from Embedded to Linked. When I move my Access project to my laptop (Vista), data is on the D:\ drive, so the picture name is invalid. Each time I use the program on the laptop, I am told that Access can't open this file. This message happens before the Form Open Event, so I can't trap it.

To stop the messages, I must open the form in design view. My code knows where the pictures are, so when I switch to design view, ingCtl.Picture is valid. If I save the form, the picture name will be invalid on the desktop. If I don't save the form from design view, the picture name will continue to be invalid on the laptop.

I have 14 projects that use images, and this has gotten more that just annoying.
May 10 '09 #3

Expert 2.5K+
P: 2,653
I've created Image control with some dummy picture (Access refuses to create one if no picture file was specified).

Then in Image control properties I've changed PictureType value to Linked and cleared Picture value (it turned to "(none)").

Additionally, if you want an Image control to display whatever default picture, then you may embed this picture into the Image control and, then, before the Image control is populated with a new picture, set PictureType to Linked.

Expand|Select|Wrap|Line Numbers
  1. With imgCtl
  2.     .PictureType = 1
  3.     .Picture = strPicPath
  4. End With
May 10 '09 #4

P: 675
If I do that, I get a msgbox "Do you want to remove this picture from this form?" Stupid me, my brain intepreted that to mean 'Do I want to remove the control' because I don't consider a linked picture to be part of the form.

Thank you for setting me straight.
May 10 '09 #5

Expert 2.5K+
P: 2,653
You are welcome.

Best regards,
May 10 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.