Remove picture from Subform after go to new record

Indigo

Registered User.
Local time
Today, 19:18
Joined
Nov 12, 2008
Messages
241
I am hoping someone can point me in the right direction as I have had no luck searching for an answer to this....

I am using Access 2010 and I have a subform that contains a picture control. The image in the picture control is added to the form as follows:

Code:
    Dim a
    
    a = GetOpenFileName(ofn)
    HoldPicturePath = Trim$(ofn.lpstrFile)
        If HoldPicturePath <> "" Then
      
            Me.Diagram = HoldPicturePath
            Image46.Picture = Me.Diagram
        Else
            Image46.Picture = "Z:\Shared\Location\Machine\No Picture.jpg"
            Me.Diagram.Value = "Z:\Shared\Location\Machine\No Picture.jpg"
        End If

Once a record is added with a picture, the user clicks a button to advance to a new record on the subform and this is the code I am using for that on the Main Form:

Code:
    Me!subfrmEquipmentAdd.SetFocus
    DoCmd.GoToRecord acActiveDataObject, , acNewRec

This works fine except for one thing... the picture remains in the image control. I cannot get it to clear.

I tried:

Me!subfrmEquipmentAdd.Image46 = "Z:\Shared\Location\Machine\No Picture.jpg"

But that just got me an error.... any suggestions?
 
You have to set the .picture property of the control.

Code:
Me!subfrmEquipmentAdd.Image46[B].picture[/B] = "Z:\Shared\Location\Machine\No Picture.jpg"
 
Sorry, no good. I get an error: "Object doesn't support this property or method"
 
Aha, I got it!

Me!subfrmEquipmentAdd.Form.Image46.Picture = "Z:\Shared\Location\Machine\No Picture.jpg"
 

Users who are viewing this thread

Back
Top Bottom