• How to view an image externally?

    Author
    Topic
    #506892

    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!

    Viewing 3 reply threads
    Author
    Replies
    • #1577681

      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.

      • #1577735

        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? :confused:

    • #1577738

      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.

      Eliminate spare time: start programming PowerShell

      • #1577770

        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.

    • #1577803

      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!

      Eliminate spare time: start programming PowerShell

    • #1577833

      Thanks guys! Appreciate the help

    Viewing 3 reply threads
    Reply To: How to view an image externally?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: