Set Image Control to Null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OldBirdman
    Contributor
    • Mar 2007
    • 675

    #1

    Set Image Control to Null

    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
    Code:
    "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?
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Originally posted by OldBirdman
    When Access saves a form with a linked image control, It saves the last-used image name in the Picture property.

    ....
    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.

    Regards,
    Fish

    Comment

    • OldBirdman
      Contributor
      • Mar 2007
      • 675

      #3
      Thanks Fish. So if you open the form in design view, what are the property values for imgCtl.Picture and imgCtl.PictureT ype?

      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\Tes tImage.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.

      Comment

      • FishVal
        Recognized Expert Specialist
        • Jun 2007
        • 2656

        #4
        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.

        Code:
        With imgCtl
            .PictureType = 1
            .Picture = strPicPath
        End With

        Comment

        • OldBirdman
          Contributor
          • Mar 2007
          • 675

          #5
          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.

          Comment

          • FishVal
            Recognized Expert Specialist
            • Jun 2007
            • 2656

            #6
            You are welcome.

            Best regards,
            Fish

            Comment

            Working...