update picture form when adding new record

selahlynch

Registered User.
Local time
Tomorrow, 02:50
Joined
Jan 3, 2010
Messages
63
I have a form that is bound to a table. On this form is an image control. The picture property of this image control is set to a path which is a field in the table.

When I navigate to new records, I update the image using the following code.
Code:
Private Sub Form_Current()
    If IsNull(Me.Recordset!PictureFile) Then
        Me.Image6.Picture = ""
    Else
        Me.Image6.Picture = CurrentProject.Path & "\database1 photos\" & Me.Recordset!PictureFile
    End If
End Sub
It works great EXCEPT when I go to add a new record. When I'm adding the new record, the Me.Recordset.Bookmark is still bookmarked at the previous record. So, when I update the picture property of my image, I get the picture from the previous record. This is confusing to the user.

Any ideas about how to fix this?
 
Last edited:
Selah,

You have to set the imagecontrol to invisible, heare a bit of script no can modify. I have a separate function for the Image Directory that you may not need. This is Function.

Code:
Function GetPicture()
Dim FullPath As String
    With CodeContextObject
        FullPath = GetImageDir & .[Image File]
        If Dir([FullPath]) <> Empty Then
            .[ImageControl].Visible = True
            .[ImageControl].Picture = FullPath
        Else
            .[ImageControl].Visible = False
        End If
    End With
End Function
Simon
 
Ahh okay.

I was stuck because I thought that in order to reference data in my table I had to use
Form.Recordset![FilePath]

But I see from your code that this is unnecessary and I can just use
[FilePath]

Great, thanks.
 

Users who are viewing this thread

Back
Top Bottom