Results 1 to 10 of 10
  1. #1
    andywoj00 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Sep 2016
    Location
    South Dakota
    Posts
    9

    How to enlarge images in a form by clicking on them?

    I'm in the process of setting up a simple MS Access 2013 coin collecting database for my personal use. I imported all my coin data from Excel, setup several forms, tables, reports, etc and things seem to be working thus far. The data and the fields all seem to display correctly. I'm working on getting things functional before making it pretty later.

    On my master input form, I have (6) fields that are designated Photo1 thru Photo6 in the master table. I'm linking Photo1 thru Photo6 fields to the applicable coin photos that are stored in a photo folder on my C drive. The photos are currently displaying on the form OK as shown below, but are smaller than the original. Using full size on the form would chew up all the space.

    What I'd like to be able to do is, as those photos are displayed on the form, I want to be able to click on them and have them enlarge to their original size for viewing, no editing, either on the form window, or in another window.

    Here's a screenshot of the input form:

    Click image for larger version. 

Name:	Image3.jpg 
Views:	19 
Size:	97.4 KB 
ID:	25829

    So basically,
    1) I click on the photo as shown on the form
    2) photo opens up on the same or different window at it's full resolution
    3) I click a button or the image to close it out and come back to the input form.



    Is this possible? I have no skill in writing code, so if this is needed, I may need to have some help there. Please speak in "see Spot run" language. Any info or assistance is greatly appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You could use your computer's default application to open the photo. Here is an example of some code you could place in a doubleclick.
    Code:
    Dim strPath as string
     dim strFileName as string
    
     strPath = "c:\temp_pics\"
     strfileName = Me.NameOfControl.Value
    
     Application.FollowHyperlink strpath & strfilename
    An alternative might be changing the Hyperlink property of the control.

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    [please ignore]

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    ItsMe may have been the only way.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You can use a larger image control in another form, too. But, since you are looking for full resolution, you might as well use the default picture viewer. Another option could be to use your default browser to open a custom local website. In other words, write some real simple HTML to display each photo in a web page. Your photos would be stored locally on your hard drive.

  6. #6
    andywoj00 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Sep 2016
    Location
    South Dakota
    Posts
    9
    Quote Originally Posted by ItsMe View Post
    You could use your computer's default application to open the photo. Here is an example of some code you could place in a doubleclick.
    Code:
    Dim strPath as string
     dim strFileName as string
    
     strPath = "c:\temp_pics\"
     strfileName = Me.NameOfControl.Value
    
     Application.FollowHyperlink strpath & strfilename
    An alternative might be changing the Hyperlink property of the control.
    So type this up exactly as written? Or does some sort of value need to be put in at certain points? Also, would this have to be done for each image?

  7. #7
    andywoj00 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Sep 2016
    Location
    South Dakota
    Posts
    9
    Quote Originally Posted by ItsMe View Post
    You can use a larger image control in another form, too. But, since you are looking for full resolution, you might as well use the default picture viewer. Another option could be to use your default browser to open a custom local website. In other words, write some real simple HTML to display each photo in a web page. Your photos would be stored locally on your hard drive.
    If I go this route, where exactly would this html need to go in order for the image to display if it's clicked on on the form?

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Create a folder somewhere on your local drive. In that folder, create a new Text File using Notepad. Paste the following inside the text file.
    Code:
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>MyPageTitle</title>
    </head>
    <body>
    <img src="FileName.jpg" width="800" height="400" alt="File Not Found"/>
    </body>
    </html>
    Save your new text file and give it a name. Now, change the file extension of your text file to HTML.

    When you need to edit your new HTML file, right click it and choose Open With > Notepad.

    Another thing you could do is place all of your images in a subfolder. So, in your new folder, create another folder and name it something like 'images'. Then, the path (src) to your images would look something like ...
    Code:
    src="images/FileName.jpg"
    If you want to get real fancy, you could use Bootstrap and create responsive web pages. You can download the necessary supporting files for free. The HTML in your web pages will look a little different because they need to understand there are folders with supporting files. Just like you might have a folder named images, you would want to reference assets that support the responsive web page.
    http://getbootstrap.com/

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by andywoj00 View Post
    So type this up exactly as written?
    You will need to make adjustments for the path to the file/picture. Maybe your folder is not on your C drive. Get the folder and any subfolders correct. When you have your folder open and are looking at all of the files, click in the little address field within your Windows Explorer, towards the top of the window. If you click to the right of all of the folder names, the path should display and be highlighted. Just copy that path.
    Code:
    strPath = "c:\temp_pics\"
    You will need to dynamically assign a value to your variable. Sounds more complicated than it is. Basically, it is a variable because each file will have a different name. Maybe you can store all of the names in a table somewhere, one name for each record/row. In this example below, I have a control named NameOfControl. So you would want to change that syntax to match the name of your control that resides on your form and is bound to the field in your table that stores the File name.
    Code:
    strfileName = Me.NameOfControl.Value

    Quote Originally Posted by andywoj00 View Post
    Or does some sort of value need to be put in at certain points?
    So this is the dynamic/variable thing. Each record will be associated to a different coin/image.


    Quote Originally Posted by andywoj00 View Post
    Also, would this have to be done for each image?
    You place the VBA code behind your form, in its On Current event handler. You place it there only once. Since the code will handle the dynamics via its variables, it does not need to be repeated.

    You can open the VBA editor from Design View of your form. Click the appropriate Event via the ellipses (...). Then choose Code Builder to launch the VBA editor. You will want the On Current event. This image illustrates the Form's On Load event.
    .
    Click image for larger version. 

Name:	OnLoadHandlerLaunch2.jpg 
Views:	15 
Size:	72.6 KB 
ID:	25834

  10. #10
    andywoj00 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Sep 2016
    Location
    South Dakota
    Posts
    9
    Finally got it working as requested. Thanks to all for the assist!
    Last edited by andywoj00; 09-17-2016 at 09:29 AM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 09-15-2015, 03:08 AM
  2. Replies: 3
    Last Post: 08-03-2015, 08:24 AM
  3. Replies: 2
    Last Post: 10-19-2014, 12:23 PM
  4. Enlarge a check box
    By newtoAccess in forum Forms
    Replies: 9
    Last Post: 12-16-2010, 04:40 PM
  5. Replies: 17
    Last Post: 08-26-2009, 11:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums