Image display form

errant

Registered User.
Local time
Today, 12:44
Joined
Sep 1, 2012
Messages
16
Hi, All,

I made a form and placed image in, this image source in specific folder which is match with the ItemNo, means:
Database[ItemNo] = Folder[ItemNo.jpg] (if picture can't found then will display a unique picture - "No Picture")

This function made by VBA.
The problem when I print report then the image will show "No Picture" only, the original that I have pictures in each data, how can I make this print in report with image?

Here is the VBA quote:
Public Function GetPathPart() As String
***' Comments *: Returns the path part of a string
***' Parameters: strPath - string to parse
***' Returns **: path part
***'
***Dim db As DAO.Database
***Dim strPath As String
***Dim intCounter As Integer
***
***Set db = CurrentDb
***strPath = db.Name
***db.Close
***Set db = Nothing
*******
***For intCounter = Len(strPath) To 1 Step -1
If Mid$(strPath, intCounter, 1) = "\" Then
***********Exit For
*******End If
***Next intCounter
***
***GetPathPart = Left$(strPath, intCounter)
End Function

Private Sub Form_Current() 'Picture load
Cube = Me.txtCtnDimH * Me.txtCtnDimL * Me.txtCtnDimW / 1728

On Error GoTo err_Form_Current

***If Not Me!txtItemNo = "" Or Not IsNull(Me!txtItemNo) Then
*******Me!MtImage.Picture = GetPathPart & Me!txtItemNo & (".jpg")
***
***Else
*******Me!MtImage.Picture = ""
***End If
*******
exit_Form_Current:
***Exit Sub
***
err_Form_Current:
***Me!MtImage.Picture = GetPathPart & "NoPicture.jpg"
***Resume exit_Form_Current
End Sub
 
Firstly, I not sure why you are using brackets (".jpg")

Here some Functions
Code:
Private Function GetPictureDir() As String
    
    GetPictureDir = "C:\Databases\Images\"

End Function

Private Function GetPicturePath() As String
        
    With CodeContextObject
        GetPicturePath = GetPictureDir & .[ImageFile]
    End With
End Function

Function GetPicture()
    With CodeContextObject
        If Dir(GetPicturePath) <> Empty Then
            .[ImageControl].Visible = True
            .[ImageControl].Picture = GetPicturePath
        Else
            .[ImageControl].Visible = False
        End If
    End With
End Function

Simon
 
for the ("JPG"), this is because the form only show the file name without extension.
By the way, is this Private function in the form? I understand the structure but don't know how to use this function for the report, can you tell me more?
I'm really new in VBA.
 
Ok, that's more simple, I made the default value for the pictures path to update table detail.
Pictures = "R:\Picture\" & [ItemNo] & ".jpg"
question is how can I use this path to show picture in report?
 
I got it, this is really simple that I put Picture path and wrote the code
Private Sub Report_Current()
Me.MtImage.Picture = Me.Pictures
End Sub

then I can see picture in the report, this is wonderful but there have "Compile.error"
Method or data member not found
what is the problem with this?
 
I got it, that's the Me.Pictures should show Pictures only
really don't know what is the Me. mean..
 
Remember I did change the file names!

Simon
 

Users who are viewing this thread

Back
Top Bottom