Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Load Multiple Images 2 < Load Multiple Images | Load Multiple Images 3 >
Back to Load Multiple Images 2    Comments List
Pinned    Upload Images   Link   Email  
Transcript
Richard Rost 
            
4 months ago
This is part two of my video series on loading multiple images into your database. If you haven't watched part one yet, go watch that first and then come on back.

Alright, so in yesterday's video we got our contact table all set to hold multiple images for a customer. We've got a field put in our contact form right there to display the picture. Now we're going to start actually putting some coding in here to get these pictures in from files on the hard drive.

Now the first thing I want to do is drop a status box on here so I can see what's going on. Remember I got the status box out here. If you haven't watched my video where I build the TechHelp free template, the status box is basically just it's kind of like my replacement for message box. I hate message box and stuff just pop it up in your face. So we are going to just literally copy this status box copy and we're going to paste it in here, and I'm going to put it down on the bottom.

Now I love using status box, especially when I'm developing because I can get all kinds of information and display it for myself. But then even after I'm done, this is a great thing for the user too because the user can then see some stuff too like, you know, copied for files or whatever you want to say. I'll make it big right now. Usually, I make it nice and large when I'm developing, and then when I'm done I make it smaller and just put in here messages for the user to see.

We also are going to need to steal the code if you go into the form module for the main menu. Let me move this over here so you can see it better. There we go. We need to grab this status subroutine right here, so copy that and if you want to you can go view project explorer and then open up the contact form right there. That's the code for the contact form. There's nothing in here right now, and then just paste that in. So now that form has that sub in it.

Okay and it's unique to the form. Alright so we got that. We're good there. We close and reopen the main menu and in here now we have a little status box. We can put messages in here. Alright this is handy to see what's going on. Let's get this guy out of the way. That's just a hidden customer ID which it's got to be on the form for some other purposes, but we don't need to see it. That's why it's red.

I'm gonna put two buttons on here. One button is to open up the import folder. It just makes it handy to open up that folder because if you want to add, you know, pictures real quick you hit the button it opens up the folder then you just drop the pictures in that folder. So let's go to form design and we're gonna grab a command button drop it right meow cancel the wizard and we're just gonna put on here open import folder and you can make that text smaller if you want.

I like to go to nine point for stuff that's not important and we can make the button a little bit smaller like that. Okay so this is our open the import folder button. Let's change the name of it to open import open import folder button and let's right-click on it go to build event. Okay what are we gonna do in here now we're gonna open up a folder in a file explorer window right that points to that folder location where our import folder is so we can just easily drop files in there.

So to run another program we use the shell command. Shell says I want you to just run something else you can use it to run Word, Excel, notepad whatever we're gonna use it to run Explorer. Now explorer.exe it's part of Windows it should be in your path you don't have to specify the exe there and then after that we're gonna put the full path to the import folder.

Okay but that's got to be inside of quotes so that means we need double double quotes in here right that puts an actual literal quote in the string. Close that string and current project dot path that's our database folder and import folder backslash and then we got to close the quotes in the string and then close the string. See what we're getting there? We're getting current project dot path so that's c colon backslash whatever database that is a slash import folder and that whole thing is inside of quotes and that's necessary.

Okay and then one more parameter out here comma how do you want to see it? I want to see VB normal focus otherwise you won't see it it just runs in the background hidden so make sure you put VB normal focus there. Okay save it give it a debug compile I'm gonna close that let's close it close it open it and hit the open import folder button and it opened on my other screen but it opened up down there I got a two monitor setup so this opened up to the right folder but on my other screen and yeah you can control that and move Windows around but that's a whole different video.

Okay so here it is right there good to go now we got a spot where we can very easily drop our files into in fact while I'm at it we're at that point now let me open up the import folder again and I'm gonna copy a bunch of images to it so we got some stuff to work with and there we go got a bunch of pictures in here that my routine can then import okay we don't need this let's close that now all right now we're ready to make a button to actually perform the import so copy this button copy paste right and then we're gonna put on here import images yes I know import is not exactly the right technical term because we're not importing stuff into the database but as far as our user's concerned the database is importing the information for the images okay okay it's a training issue all right this will be our import button right click build event.

Alright here's where the code gets handy and I'm gonna turn off this just to save some space. The first thing is we're gonna set variables to where our images path and our import path is so we need dim images path as a string and import path as a string and we'll set those up as images path equals current project dot path and images and our import path where the stuff ghost or where the stuff comes from current project dot path and import folder. And it's nice to use current project dot path because if your database moves everything's relative right if you're you know if you if you're developing locally and it's in C colon backslash database then you move it up to the server well now the database path is you know up there you can you can change you can change this current project dot path to something else you could put it in a you know a global constant or whatever.

Alright we're gonna start off by telling the user something's happening right status importing images I'll put it in the status box. I'm gonna want to counter so I know how many images were imported so I could tell the user hey you know six images imported so let's make a counter variable right counter as long and we'll start that off by saying counter equals zero before anything happens always initialize your variables.

Alright now the next thing I want to do is get a list of the files in the import folder and to do that I'm gonna use the dir command. Now if you're familiar with DOS and Windows command prompts at all you type in dir and it gives you a list of the files and folders that are in the file folder that you specify right. I open up a command prompt type in dir and there's all the files and folders in that folder.

Okay same thing in VB dir will just loop through all the files and folders in the current folder and bring them back to you one at a time so let's make another variable over here we'll call it file name as a string and down here I'm gonna say file name file name file name equals dir and then you want to specify the path that you want to search in so it's going to be my import path with a star dot star on the end of it that says give me all of the files and yes I know I spelled import path wrong and this is one of the reasons why when I'm typing I like to do all lowercase and I don't know why I haven't been because if I do this I can immediately see it didn't camel case right it didn't capitalize automatically and that would have just visually told me I typed it in I spelled it wrong I'd say 90 of my mistakes are spelling errors all right and yeah there are some other options for dirt I cover them in my access developer course you can look through directories you can look through hidden files all that kind of stuff, but this will just bring you back a list of the normal files that are in that folder one at a time.

Okay and we can do that with a while loop we'll say while file name is not an empty string because when you're out of files or if no files exist in the first place then the dirt command will return an empty string. Alright so you do your while loop you put your while end down here and in the middle when you're done doing whatever processing you're gonna do you say file name equals dir just dir by itself and that will go out and get the next file using the parameters that you specify it up top. Okay that's all you got to do and then in the middle here you'll do some stuff how about for now we just status that file name so we could see what we're getting right.

That's what I like the status for instead of message boxing it then you got us hit enter enter enter. Alright let's see what we get so far save it debug compile go back over here close it open it and let's hit the button click oh look at that I'm gonna zoom in so we can see it shift F2. Alright now remember the status box runs backwards so importing images goes first and then here is a list of all of the files in that folder that's pretty cool right.

Now we just have to process each one of these files we got to figure out what kind of a file it is JPEG GIF whatever make sure it's allowed right we don't want there to be a text file or PDF in there we're gonna ignore those to have to figure out the extensions and then we have to write some code to simply add that as a record in the contact table and we will start doing all of that in tomorrow's class. So tune in tomorrow same bat time same bat channel for part three or of course if you remember you can watch it right now because I'm gonna keep recording today and it'll be posted as soon as I'm done tonight.

But that is gonna be your tech help video for today. I hope you learn something live long and prosper my friends I'll see you tomorrow for part three. A special thank you and shout out to our diamond sponsor Juan Soto with access experts software solutions their manufacturing experts specializing in Microsoft access and SQL server Juan is a 13-time Microsoft access MVP check them out at access experts.For readability:

If you enjoyed this video, please give me a thumbs up and post any comments you may have below. I do try to read and answer all of them as soon as I can. Make sure you subscribe to my channel, which is completely free. Click the bell icon and select all to receive notifications when new videos are posted.

Want to learn more? Click the show more link below the video to find additional resources and links. YouTube does a pretty good job of hiding it. It's right down there, see this part of the description here, right? The name of the video is up here. There's a little show more down there, right down at the bottom. It's kind of hard to find, but once you click on that, you'll see a list of other videos, additional information related to the current topic, free lessons, and lots more.

YouTube no longer sends out email notifications when new videos are posted as they used to do. But if you'd like to get an email every time I post a new video, click on the link to join my mailing list. You can pick how frequently to get emails from me, either as they happen, daily, weekly, or monthly.

Now, if you'd like to become a paid member of my channel and receive all kinds of awesome perks, click on the join button. You'll see a list of all the different membership levels that are available, each with its own special perks, including my extended cut videos, access to my code vault (lots of VBA source code in there), template downloads, and lots more. I'll talk more about these perks at the end of the video.

Even if you don't want to commit to becoming a paid member and you'd like to help support my work, please feel free to click on the tip jar link. Your patronage is greatly appreciated and will help keep these free videos coming. I've got some puppies to feed, but don't worry. No matter what, these free TechHelp videos are going to keep coming. As long as you keep watching them, I'll keep making more, and they'll always be free.

Now, if you really want to learn Access and you haven't tried my free Access Level One course, check it out now. It covers all the basics of Microsoft Access including building forms, queries, reports, and more. It's over four hours long. You can find it on my website or on my YouTube channel. I'll put a link down below you can click on. And did I mention it's completely free? The whole thing, free. Four hours. Go watch it.

Okay, okay. A lot of you have told me that you don't have time to sit through a four-hour course, so I do now have a quicker Microsoft Access for Beginners video that covers all the basics faster, in about 30 minutes. And no, I didn't just put the video on fast forward. But I'll put a link to this down below as well.

Now, if you like Level One, Level Two is just a dollar. That's it, one dollar. That's another whole, like, 90-minute course. Level Two is also free for paid members of any level, including supporters. So, if you're a member, go watch Level Two. It's free.

Okay, want to get your question answered in a video just like this one? Visit my TechHelp page and send me your question there. Members get priority, of course. While I do try to read and respond to all of the comments posted below in the comment section, I only have time to go through them briefly a couple of times a month, and sometimes I get thousands of them. So send me your question here on the TechHelp page, and you'll have a better chance of getting it answered.

And while you're on my website, be sure to stop by my Access Forum. We've got lots of lively conversations about Microsoft Access and other topics. I have a fantastic group of moderators who help me answer questions. Shout out to Alex, Kevin, Scott, Adam, John, Dan, Juan, and everybody else who helps out on the site. I appreciate everything you do. I couldn't do it without you.

Be sure to follow my blog, find me on Twitter, and, of course, on YouTube. Yeah, I'm on Facebook too, but I don't like Facebook. Don't get me started.

Now, let's talk more about those member perks. If you do decide to join as a paid member, there are different levels: Silver, Gold, Platinum, and Diamond.

Silver members and up get access to all of my extended cut TechHelp videos, one free beginner class every month, and some other perks.

Gold members get all the previous perks, plus access to download the sample databases that I build in my TechHelp videos, plus access to my code vault where I keep tons of different functions that I use, the code that I build in most of the videos. You'll also get higher priority if you do submit any TechHelp questions. Now, answers are never guaranteed, but you do go higher in the list for me to read them. And if I like your question, you got a good chance of it being answered. You'll also get one free expert-level class each month after you finish the beginner series.

Platinum members get all the previous perks, plus even higher priority for TechHelp questions. You get access to all of my full beginner-level courses for every subject. I cover lots of different subjects like Word, Excel, VBA, ASP, lots of different stuff, not just Access. These are the full-length courses found on my website. You get all the beginner ones. In addition, once you finish the expert classes, you get one free developer class per month, so lots of training.

And finally, you can also become a Diamond sponsor. You'll have your name or your company name listed on a sponsors page that will be shown on each video as long as you're a sponsor. You'll get a shout-out in the video and a link to your website or product in the text below the video and on my website.

So, that's it. Once again, my name is Richard Rost. Thank you for watching this video brought to you by AccessLearningZone.com. I hope you enjoyed. I hope you learned something today. Live long and prosper, my friends. I'll see you again soon.

TOPICS:
- Drop a status box on the form
- Copy and paste the status box
- Create a status subroutine in the form module
- Remove unnecessary elements from the form
- Add a button to open the import folder
- Write code to open a folder using shell command
- Create variables for images path and import path
- Display import status in the status box
- Initialize a counter variable for tracking imports
- Use the dir command to list files in the import folder
- Implement a while loop to process files in the folder
- Display file names in the status box

COMMERCIAL:
In today's video, we dive into part two of our series on loading multiple images into your database. We begin with setting up a status box to track what's happening, especially handy during development. Then, we add coding to import pictures directly from your hard drive. We walk through adding a button to open the import folder easily and another one to perform the image import. Along the way, we use the shell command and create a loop to handle file importing. It's all about making the process seamless and user-friendly. You'll find the complete video on my YouTube channel and on my website at the link shown. Live long and prosper my friends.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Load Multiple Images 2.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 12/14/2024 9:02:15 AM. PLT: 1s