Displaying jpgs

satkin2

New member
Local time
Today, 20:52
Joined
Aug 5, 2006
Messages
8
Hi,
I've looked at various threads on here about how to show images, and I've not been able to get any of them working for me, so I'm hoping someone on here will be able to help me.

I've got a continuous form which I choose a record from and open in a seperate form, (frmPicture).

On frmPicture is have the ID, Name and Path of the image in text boxes and an image frame.

What I'm trying to do is upon loading the form, show the image in the image box.

I am opening the individual record okay, but the image doesn't show. I've got it set to a default 'No Image To Show' picture, but this doesn't change.

This is the code I've currently got...

Private Sub Form_Load()
On Error GoTo ErrorHandler

Dim imgPath As String

imgPath = Me!crdPath.Text
imgPhoto.Picture = imgPath

ErrorHandler:
Select Case Err.Number
Case 2220
imgPath = "C:\Documents and Settings\Katy\My Documents\My Pictures\Card Photos\no image.jpg"
imgPhoto.Picture = imgPath
Resume
End Select

End Sub

I'm not sure how/what needs changing so some help would be really appreciated.

Thanks

Steve
 
Think you've got the right idea, but a few suggestions. If you firstly put the code into the OnCurrent even, then it will be updated for every record when you scroll through records.

As for the showing of the image, i've got a very similar thing running on one of my forms, where the picture location is put into a field on the form, and loaded into the image box. Try using:

Me.Image.Picture = "(name of text box holding file location)"

image is the name of the image box so whatever it is for you?

With this code you may not need to declare any variable either, the code (one part) is shown below:

If IsNull([txtPath]) Then
Me.Image.Picture = "D:\Database\NoPicture.JPG"
Else
Me.Image.Picture = Me.txtPath
End If

txtPath is the box storing the path of the image
Image is the image box

I haven't declared any variables at all.



Hope some of this was of help
 
Hi agehoops,

That was a great help. It's working :) .

However, some of my entries into the database are not identical to the actual image filename. The name of the card is entered into the database which then fills in the path.

ie.
Database entry:
Card Name - Good Luck
Database Path text - C:\Documents and Settings\Katy\My Documents\My Pictures\Card Photos\Good Luck.jpg

Real file name:
Path - C:\Documents and Settings\Katy\My Documents\My Pictures\Card Photos\good luck.jpg

When the cases are different like above then the photo doesn't show. Is there a way to get around this?

Thanks
 
i'm not 100% sure about small errors like that, i assume you mean the "good luck.jpg" not having a capital g??

you could use a file dialog box on a command button which would bring up an Open File box where you can select the image that you want, which will put in the correct file location exactly. Would also save the user having to type in the files location and making the mistakes?? Or if you wanted the user to still input this, you could have a code that loads the imaged, and then when there is an error, the error handler opens the File Open dialog box to select the correct file location to replace it with.
 

Users who are viewing this thread

Back
Top Bottom