Remove picture from Subform after go to new record (1 Viewer)

Indigo

Registered User.
Local time
Today, 18:54
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?
 

Pyro

Too busy to comment
Local time
Tomorrow, 07:24
Joined
Apr 2, 2009
Messages
126
You have to set the .picture property of the control.

Code:
Me!subfrmEquipmentAdd.Image46[B].picture[/B] = "Z:\Shared\Location\Machine\No Picture.jpg"
 

Indigo

Registered User.
Local time
Today, 18:54
Joined
Nov 12, 2008
Messages
241
Sorry, no good. I get an error: "Object doesn't support this property or method"
 

Indigo

Registered User.
Local time
Today, 18:54
Joined
Nov 12, 2008
Messages
241
Aha, I got it!

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

Users who are viewing this thread

Top Bottom