Viewing images in access DB (1 Viewer)

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
Previously I was adding the images as an attachment but even with reduced quality images the size of the DB was getting big & bloated. I was given the code to get & store the link to the file on my local drive.

It all works great except for when I click the 'view icon', it brings up the windows 10 "how do you want to open this file" suggesting one app and listing other image viewing app.

Even with the Windows 10 photo app set to open jpg by default and then clicking the 'always use this app' checkbox the same happens the next time you try to view an image. clicking ok works and image opens to view.

I'm using Call ExecuteFile(Me.FullFileName, "Open") to open the image. Is it possible to add the name of the app/program to the command line to bypass the option box and open the image directly form the command line?
 

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
You need to add an image control to your form and set its control source to the file path
Have a look at this example app which shows how you can view thumbnails of all images in a folder: http://www.mendipdatasystems.co.uk/folder-image-viewer/4594429467

That looks good but how would I use the code to be able to add up to 4 images to an existing form for each record in the DB so only the images associated with the record were in a list on the form and moving to the next record would change to available images?

I'm getting more used to working with code but not good with it. Mike60Smart has been helping me a lot.
 

June7

AWF VIP
Local time
Today, 08:46
Joined
Mar 9, 2014
Messages
5,488
Agreed, if you want to dynamically display images within form or report, use an Image control with its ControlSource property set to field that stores file path.

If each record must have 4 images associated with it, either use 4 fields or a related table where each image is a record.

ControlSource can also be an expression that calculates file path.
Example: =CurrentProject.Path & "\" & [EmpID] & "1.jpg"

If you want a cascading combo or listbox that conditionally lists images, that will require code to Requery the combo/listbox RowSource SQL. Then Image control expression can reference the combo/listbox to display only the selected image.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 17:46
Joined
Jan 14, 2017
Messages
18,247
And either have four image controls on the form or allow users to move through the images in turn
 

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
Agreed, if you want to dynamically display images within form or report, use an Image control with its ControlSource property set to field that stores file path.

If each record must have 4 images associated with it, either use 4 fields or a related table where each image is a record.

I do have a table with all the images as an individual record and shown on the main form in subform combobox/list. clicking the viewer icon opens the file via an external viewer.

Displaying dynamically in a subform or on the main form would be better than viewing externally. What code does that?
 

June7

AWF VIP
Local time
Today, 08:46
Joined
Mar 9, 2014
Messages
5,488
Apparently I edited previous post after you read it. Review again. VBA is not required. Image control has ControlSource property.
 

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
That looks good but how would I use the code to be able to add up to 4 images to an existing form for each record in the DB so only the images associated with the record were in a list on the form and moving to the next record would change to available images?

I'm getting more used to working with code but not good with it. Mike60Smart has been helping me a lot.


Here is an image of the subform as is.
 

Attachments

  • 1.jpg
    1.jpg
    30.1 KB · Views: 97

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
When I navigate to the next record the files shown in that combobox/subform automatically update to to the images associated with the new record.

I appreciate you trying to help me but I'm not that familiar with access to work out how to do what you are saying to do it myself. Unfortunately I still need step by step instructions for new things like this.
 

June7

AWF VIP
Local time
Today, 08:46
Joined
Mar 9, 2014
Messages
5,488
Most likely form uses a parameterized query as RecordSource. If you want to provide db for analysis, follow instructions at bottom of my post.

Adding an Image control to form would not be much different from adding a textbox.
 
Last edited:

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
Most like form uses a parameterized query as RecordSource. If you want to provide db for analysis, follow instructions at bottom of my post.

Adding an Image control to form would not be much different from adding a textbox.

Sorry it took so long. Not sure why but I couldn't delete a lot of the records so have just cleared the controls.

I would like to view the images from the 'Finds Details' form. There is a space on the form that can be used or display in a pop up form (second choice)

At the moment the files are all in the MDF Database folder on the 'D' drive. I've zipped 4 images, 2 for each of the 2 records which is the normal number but a record can have up to 4 (normal max).
I tried to upload the DB but I need a 'TOKEN' from an admin??????
 

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
Misread the error, it's missing a SECURITY TOKEN and I need to contact an admin.
 

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
Going to try again.

It would appear that my DB was over the 2 meg limit. I've now got it down in size and uploaded it.
 

Attachments

  • Metal Detector Finds Database.accdb
    1.4 MB · Views: 127

June7

AWF VIP
Local time
Today, 08:46
Joined
Mar 9, 2014
Messages
5,488
Should not be difficult to modify form f_Method1_Local to include an Image control. I don't see any attempt.

Just add the Image control from ribbon Design tab. (Scroll down and it's the last icon). When the Insert Picture dialog pops up, just cancel it. Now set the ControlSource property to FileFullName.
 

Dreamweaver

Well-known member
Local time
Today, 17:46
Joined
Nov 28, 2005
Messages
2,466
I did a number of years ago post an example but can't seem to see it so will create a new one if anybodies interested I'll make a new one



 

Attachments

  • 2018-12-01 (1).jpg
    2018-12-01 (1).jpg
    61.6 KB · Views: 572
  • 2018-12-01 (2).jpg
    2018-12-01 (2).jpg
    102.3 KB · Views: 538

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
Should not be difficult to modify form f_Method1_Local to include an Image control. I don't see any attempt.

Just add the Image control from ribbon Design tab. (Scroll down and it's the last icon). When the Insert Picture dialog pops up, just cancel it. Now set the ControlSource property to FileFullName.

I need the photo to display in the frmFinds form and as there is normally 2 and could be 3 or 4 for each record and I only want photos relevant to the displayed record showing one at a time. preferably when an icon is clicked.

I had experimented with the image control but I couldn't see the imagelink, probably because I was doing it on the frmFinds.

It would be ideal if clicking the icon (in front of the link) on the subform brought up a pop up form (changed to another form) displaying the image.

I have no idea how to do that and can't find an example anywhere.

I did what you said and it did show an image on the form but it also listed every link and every image. Not what I'm after but thanks for explaining the method. It gives me something to play with to see if I can adapt it.
 

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
I've been trying and although I can get an image to display in a new form as a pop up form it always goes to image 1 from the first record. regardless of what record I'm viewing or which one of the 2 I wish to see. ie, if I'm on record 10 and want to view image 2 of that record, how would I pass the values from FindID & FindID and/or the FillFullName over to the new from (frmImageToView)?
 

June7

AWF VIP
Local time
Today, 08:46
Joined
Mar 9, 2014
Messages
5,488
Why a popup form? All I did was add Image control to form f_Method1_Local. This is the easiest way to display the associated images on frmFind - via subform. Anything else will be complicated.
 

Dangerous

Registered User.
Local time
Today, 17:46
Joined
Oct 18, 2018
Messages
73
Why a popup form? All I did was add Image control to form f_Method1_Local. This is the easiest way to display the associated images on frmFind - via subform. Anything else will be complicated.

It doesn't have to be a pop up form, any from as long as it only shows the images belonging to the current record displayed on the finds form. There can be zero to 4 images per record (but the odd record could have more). The biggest problem with that method is viewing space. If I make the subform area larger to display 3 images, what happens when a record has 5 images assigned to it?

I did what you suggested and as soon as I switch to F_Method1_Local form it displays an image for every single image link in a long list starting at image 1 (147 links each with an image). That isn't practical as the user would have to scroll down to find the images they wanted to view. Now if it switched and retained the selected record it may work but it seems that changing forms always resets the selected count.

As I said, I'll play about with that method to see if I can get it to work as I want it to do.
 

Users who are viewing this thread

Top Bottom