Image(s) display in subform

gadjet

Registered User.
Local time
Today, 09:06
Joined
Jan 21, 2008
Messages
45
Hi,
I used some code from the MS website to enable display of images on a form based on the path stored in a text field, all worked OK until I tried to be clever and use a subform to display multiple images linked by EventID.

The problem is that, even though the record ID in the subform shows the next picture ID, when next record button is pressed, the picture remains the same.

Anyone any ideas as to what's not happening. MS code below.

Code:
Public Function DisplayImage(ctlImageControl As Control, strImagePath As Variant) As String
On Error GoTo Err_DisplayImage
Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer
With ctlImageControl
    If IsNull(strImagePath) Then
        .Visible = False
        strResult = "No image name specified."
    Else
        If InStr(1, strImagePath, "\") = 1 Then
            ' Path is relative
            strDatabasePath = CurrentProject.FullName
            intSlashLocation = InStrRev(strDatabasePath, "\", Len(strDatabasePath))
            strDatabasePath = Left(strDatabasePath, intSlashLocation)
            strImagePath = strDatabasePath & strImagePath
        End If
        .Visible = True
        .Picture = strImagePath
        '.Requery
 
        strResult = "Image found and displayed."
    End If
End With
 
Exit_DisplayImage:
    DisplayImage = strResult
    Exit Function
Err_DisplayImage:
    Select Case Err.Number
        Case 2220       ' Can't find the picture.
            ctlImageControl.Visible = False
            strResult = "Can't find image in the specified name."
            Resume Exit_DisplayImage:
        Case Else       ' Some other error.
            MsgBox Err.Number & " " & Err.Description
            strResult = "An error occurred displaying image."
            Resume Exit_DisplayImage:
    End Select
End Function
 
AFAIK, you can not show unbound images on a form in continuous mode.

See this previous post on the subject for a solution:

how to set the path
See the links to two third party options that will allow you to do this.
 
AFAIK, you can not show unbound images on a form in continuous mode.

See this previous post on the subject for a solution:

how to set the path
See the links to two third party options that will allow you to do this.

Thanks for the reply, I had a look at the thread.
Sorry I was not clear in the first post but my form is a single main form with a single subform, the subform (not continuous) has navigation buttons at the bottom, sometimes when you click next it will change to the next picture but then it will not change back to the first one, also I'm having problems triggering on an event to run the code in previous post.

It's as if the record changes but the image isn't always updated, wierd.
 
Do you have ypuir VBA code to set the picture iont he sub form's On Current event?

Please post all the VBA code including the event that you are using.

You still may want to check out the two custom controls.
 
I just had a post with similar problems with subforms... Take a look at this DB and see if it might help you with your problem.
 

Attachments

Do you have ypuir VBA code to set the picture iont he sub form's On Current event?

Please post all the VBA code including the event that you are using.

You still may want to check out the two custom controls.

I had the oncurrent event set but then I couldn't close the main form because it kept loading the picture but I tried it again this morning with the oncurrent event of the subform and it seems to work even though when I click the close button on the main form it seems to trigger the image update on the sub form but it still closes.

I'll have a look at the the other sample to see if I can do it better but it seems to work so far.

Thanks for your help
 

Users who are viewing this thread

Back
Top Bottom