image viewing in a form (1 Viewer)

ChrisC

Registered User.
Local time
Today, 09:40
Joined
Aug 13, 2019
Messages
90
Morning all,

OK, my searchable image database is coming along thanks to advice and a sample database from this forum, and I have worked out how to show an image path on my computer for each part in the table.

What I want to be able to do next, in my search results form, is to be able to click on the path (as a hyperlink) and have the image show in an imagebox on the same form. The image should change as I click on different images.

Is this possible? Are hyperlinks the wrong way to go?

many thanks as always,
Chris
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:40
Joined
May 7, 2009
Messages
19,169
just add the path of the image (saved on fieldname) to the Picture property of the image.
don't use Click event instead use Dbl-Click event of the textbox.

Me.Image0.Picture = Me.imagePathFieldName
 

isladogs

MVP / VIP
Local time
Today, 09:40
Joined
Jan 14, 2017
Messages
18,186
Use a text field for the path. Hyperlink datatype can cause problems.

Agree with arnelgp.
The reason for using the double click event is so you can if necessary select the item for editing using a single click.
However the sample database I supplied in your earlier thread should have shown you how to do this.
 

ChrisC

Registered User.
Local time
Today, 09:40
Joined
Aug 13, 2019
Messages
90
Thanks folks!

so to get it right in my head:

I have a picture box simply called "ImageBox"
I have my text field that contains the image path which is called "ImageFile", which is called from my main item table and appears


The code therefore that I put in the On Dbl Click property of the ImageFile text box would be:

Me.ImageBox.Picture = Me.ImageFile

?

When I double click on it however, I get the error message pop up to say that the database "cannot find the object 'Me'".

sorry to be dumb on what is almost certainly a simple thing!
 

isladogs

MVP / VIP
Local time
Today, 09:40
Joined
Jan 14, 2017
Messages
18,186
You need to refer to the name of your textbox control which may not be the same as the field name
 

ChrisC

Registered User.
Local time
Today, 09:40
Joined
Aug 13, 2019
Messages
90
Hi Colin,

text box name and control source are both "ImageFile".

could this be causing some kind of conflict?

thanks
 

isladogs

MVP / VIP
Local time
Today, 09:40
Joined
Jan 14, 2017
Messages
18,186
It shouldn't cause a conflict.
The Me. syntax only works on the same form but that's not an issue here.
There must be something else that's not quite right on your form.

As a test add another text box temporarily and set its value equal to me.imagefile. Does that error?
 

ChrisC

Registered User.
Local time
Today, 09:40
Joined
Aug 13, 2019
Messages
90
didn't do anything im afraid (although I wouldn't rule out me doing it wrong!!)

ive attached the db - as you will see, it is an amended version of Allen Brownes.

the existing image is simply a place holder.


EDIT - I did try to attached the DB, but for some reason it is over 10mb, despite having only 8 product lines in it and the only image (the place holder) is only 500kb. I will have a play around and will return!
 

ChrisC

Registered User.
Local time
Today, 09:40
Joined
Aug 13, 2019
Messages
90
DB now a "better" size and attached!:)
 

Attachments

  • Parts Catalogue 3.02.accdb
    636 KB · Views: 65

isladogs

MVP / VIP
Local time
Today, 09:40
Joined
Jan 14, 2017
Messages
18,186
Always compact & zip before uploading

You did do it wrong. You should have created an event procedure for the double click event:

Code:
Private Sub ImageFile_DblClick(Cancel As Integer)
    Me.ImageBox.Picture = Me.ImageFile
End Sub

See attached & check if it now works.
BTW I recommend NOT using jpg images. These don't always work well with Access. PNG format is much better
 

Attachments

  • Parts Catalogue 3.02.zip
    37.2 KB · Views: 79

ChrisC

Registered User.
Local time
Today, 09:40
Joined
Aug 13, 2019
Messages
90
You Sir, are a genius. thank you!

So for my understanding, for this type of thing (i.e. updating of fields) would it always (or at least most of the time) need to be done through an event procedure?

it works perfectly - thank you again.

Chris
 

isladogs

MVP / VIP
Local time
Today, 09:40
Joined
Jan 14, 2017
Messages
18,186
Yes!
There are some things you can place directly in the property sheet but not what you attempted
 

ChrisC

Registered User.
Local time
Today, 09:40
Joined
Aug 13, 2019
Messages
90
excellent, thanks very much for your help.

solved!
 

isladogs

MVP / VIP
Local time
Today, 09:40
Joined
Jan 14, 2017
Messages
18,186
You're welcome. Good luck with the rest of your project
 

Users who are viewing this thread

Top Bottom