Results 1 to 7 of 7
  1. #1
    New Lounger RedWagnum's Avatar
    Join Date
    Sep 2016
    Location
    San Antonio, TX
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question How to view an image externally?

    Hello all. First post!

    I'm using Access 2003 to create a video database. I have much of it working like I want but there is one thing I cannot figure out how to do. On my data input form I have a place to input an image of the video cover, linked image, works fine. I would also like to add an "index" image (picture containing thumbnails from the video) to the database but displaying the image in a form is not going to work (large image, small form). What I want to do is have three buttons: "Add Index...", "Remove Index", and "Show Index." The first two buttons do the obvious and are working fine with the cover images. What I want to happen is on a "Show" click, send the path to Windows Photo Viewer to display the index. Come to think about it, the same technique should work to add a fourth button "Watch Video" right?

    Be gentle with me! Although I have piddled around in Access before I am really a newbie. Heck, I just learned about sorting and filtering! Any ideas, code samples, or other help is appreciated. I think I cot the code that got my cover images working from here so I hope someone can help me with this.

    Thanks!

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts
    Pretty simple. Assuming you know the location and name of the file in question (let's assume it is in a variable named strFullFileName), the code behind the button to view the file would be:

    Application.FollowHyperlink strFullFileName

    Windows will open it in the application that is the default for that file type.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. The Following User Says Thank You to MarkLiquorman For This Useful Post:

    RedWagnum (2016-09-14)

  4. #3
    New Lounger RedWagnum's Avatar
    Join Date
    Sep 2016
    Location
    San Antonio, TX
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MarkLiquorman View Post
    Pretty simple. Assuming you know the location and name of the file in question (let's assume it is in a variable named strFullFileName), the code behind the button to view the file would be:

    Application.FollowHyperlink strFullFileName

    Windows will open it in the application that is the default for that file type.
    Thanks Mark! I was able to get that to work - sort of.

    I am using the attached ImageDb.zip as a basis for all this. For testing I was able to modify the cmdPreview_Click() Sub to display an image file externally. Works.

    My problem now is that I can't get the file path into the database. I have a background of programming in BASIC, QuickBASIC, and Z80 Assembler though it's been nearly 30 years since I used any of it. I recall that I used to clone subroutines and functions to use on a different set of variables. Change the Sub name and variables and poof - done. VBA does not seem to like that - at all. I tried cloning the cmdInsertPic_Click() Sub, changing the referenced of cmdInsertPic to cmdInsertIdx and the field name from [PicFile] to [IdxImg] which I added to the database. Everything just turns to poo after that. WTH? It's the same procedure, I just need it to dump the path into a different field. What am I doing wrong?
    Attached Files Attached Files

  5. #4
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,726
    Thanks
    147
    Thanked 156 Times in 149 Posts
    When you say that everything turns to poo, can you be more explicit as to what happens please. I have done what you have (I assume you're talking about copy and paste) without any poo showing up (other than any errors I have in my code) so it would be useful to know what the issue is. Possibly one way to get round this is to create an empty sub with the relevant first and last lines then paste in between them and delete the redundant lines.
    Talk is cheap because supply exceeds demand

  6. #5
    New Lounger RedWagnum's Avatar
    Join Date
    Sep 2016
    Location
    San Antonio, TX
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by access-mdb View Post
    When you say that everything turns to poo, can you be more explicit as to what happens please. I have done what you have (I assume you're talking about copy and paste) without any poo showing up (other than any errors I have in my code) so it would be useful to know what the issue is. Possibly one way to get round this is to create an empty sub with the relevant first and last lines then paste in between them and delete the redundant lines.
    More explicit? About poo?? Not in public!

    Copy and Paste was my problem. I was just opening the properties of a button, going into the VB editor from the On Click [Event Procedure] and C/P the code I wanted to use. I discovered it don't work like that, hence the "poo." As Stephen McCaffrey (Kurt Russell) told his little brother Brian (William Baldwin) in Backdraft "You're not doing it right!" I played around with the Insert Procedure command and got closer. Then I typed the procedure name in the Name box in the Property sheet and bingo. That got me where I needed to be. I did my C/P, changed the code where needed and Poof, no more poo. Works as advertised - I can input the cover, which displays in the form, clear the cover, input the index image, clear the index image, and display the index image in Windows Photo Viewer.

    As you can clearly see, I am a complete newb when it comes to Access and VBA. Your comments inspired me to just poke around and see what does what. I really appreciate the fact that you didn't just dump on me for not being able to do what (I would think) should be a simple task. And kudos @MarkLiquorman for providing the line of code that made the external image viewing work for me.

    I have much to learn and will have more questions in the future. Queries are a complete mystery to me right now and I know I will need to use them in the future. Oddly, reports seem pretty straightforward to me. But there is much more.

    Anyway, Thanks for your help! Hope y'all will help me again in the future.

  7. #6
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,726
    Thanks
    147
    Thanked 156 Times in 149 Posts
    RedWagnum, nothing's simple if you don't know how to do it, so I, and others on this forum, wouldn't dump on anyone (poo or otherwise)! You were doing something I hadn't done (well not for a while), so it's possible that it wouldn't work as you've found. Anyway, I'm glad you found your way to do what you want.
    Queries are quite straightforward so I don't think you need fear them - well not until you get into inner and outer joins or the like!
    Talk is cheap because supply exceeds demand

  8. The Following User Says Thank You to access-mdb For This Useful Post:

    RedWagnum (2016-09-15)

  9. #7
    New Lounger RedWagnum's Avatar
    Join Date
    Sep 2016
    Location
    San Antonio, TX
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks guys! Appreciate the help

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •