| |
| |
|
Microsoft Access
Imaging Seminar
Work with Images and
Objects in Access |
| |
|
This seminar will teach you how all about working with
images, pictures, graphics, OLE objects, attachments, and
pictures from the Web. You will learn how to store pictures in your
database, and how to work with images that are NOT stored in your
database. You'll also learn how to work with the new Attachment data
type.

This seminar came
about because one of my customers had a need to work with a large number
of images in his database, but storing pictures in an Access database is NOT a very efficient use of space. Your database gets
big and slow very quickly.
So, in this seminar,
I will show you a technique for selecting a file by
browsing your drives, copying that file to an Images
folder, and then displaying that image in your database forms and
reports WITHOUT storing it in the database.
But...
we don't stop there. Since we're going to learn about images,
we might as well learn everything
about images. We'll start with basic OLE
objects (bound, unbound, linked, embedded, etc.) and move right into VBA
coding for Image controls. You'll learn about the new
Attachment field type in Access 2007 (but don't worry,
almost everything else is perfectly valid for Access 2000 and 2003
users) and lots more.
Click here for a video showing what's covered in this
seminar:

Click
to Play - Seminar Preview

|
| |
|
Seminars
-
Access Imaging |
|
Description: |
Learn how to work with images and other types of objects in your
Access databases. |
|
Versions: |
I will
use Access 2007,
however most of the lessons are valid for all versions of Access back to
2000. I will show any differences between 2007 and 2003. The
lesson on Attachments is specific to 2007. |
|
Pre-Requisites: |
Access 101 - 104 a must
Access 201 - 207 highly
recommended Access 301 -
329 very helpful |
|
Running Time: |
3 hours,
32
minutes |
|
Cost: |
$89 |
|
|
|
This
seminar has several main goals. You will:
1.
Learn about the different types of OLE objects
2.
Discuss the most efficient way to work with images
3. Embed and Link OLE objects into your tables and
forms
4. Work with non-image objects (spreadsheets,
documents)
5. Display external images in your forms & reports
6. Browse your hard drive to select a file
7. Copy files to a central "Shared Images Folder"
8. Display images found on Web sites in your Database
9. Work with the new Attachment type in Access 2007
We will begin by learning about all of
the different types of objects you can use in Microsoft Access. You'll
learn about bound and unbound OLE objects,
images, linking vs. embedding, non-image objects, when and when
NOT to store images in your database, and you'll learn
about the new Attachment data type.

Next we'll build a
table and form to store embedded OLE objects right in
our database tables. This is OK if you don't have a very large number of
images to work with. You'll see how easy it is to edit these images in
place.

In the next lesson, you'll see how easy it is to work with non-image
objects in your database. We will embed a Microsoft Excel
spreadsheet into a database form and give our users the full
functionality of Excel without ever leaving Access.

Next you'll see how we can embed a company logo ONCE in
a single form, and then use that same image in all of our other forms
and reports without making separate copies of it. This saves a lot of
space in our database.

We will then learn how to work with the Image control.
This allows us to specify the path and filename of a picture file on our
hard drive (or network) and view the image without having to store it in
the database.


Next we're going to look at the Microsoft Common Dialog Control.
This was an ActiveX control that shipped with Access 2003 and earlier,
but is no longer available in 2007. It allows you to quickly and easily
browse for a file on your hard drive.

Don't worry, Access 2007 users. I've got a solution for you. Using a
little bit of VBA code, we can access that Common Dialog
window without a special ActiveX control.

Once we learn how to select a file, now we can copy that file up to a
central Shared Images folder (or just your database
folder if you prefer). This way we can keep all of our images together
in one place, and even rename them if we want. If you're working on a
network, you want to put your images where everyone has access to view
them. Don't panic... I will explain all of the VBA
programming code you need to know to get this to work.

Next you'll see how you can give your end-users the ability to actually
EDIT those pictures using Microsoft Paint. Even though
the images aren't stored in the database, we can launch Paint and load
up the pictures with just a few lines of VBA code.

If you have a Web site with images on it, you can view
those images and use them in your Access database forms and reports.
This is especially handy if you already have all of your product
pictures online. Just point to them, and voila...

Next, Access 2007 users will learn how to use the
Attachment data type. You can store multiple objects (pictures, text
files, documents, spreadsheets, you name it) as attachments to database
records... just like Email attachments.


This
seminar is perfect for anyone who wants to learn
how to work with images, pictures, or any kind of objects in Microsoft
Access databases.
This
seminar is long (over three hours) but it's broken up into
easily managed lessons of about 10 minutes each. You can sit down,
watch a lesson, review the material, test the code out yourself, and
experiment. Do a little bit each day. It's long, but it's comprehensive
- you won't miss a single step as I've recorded everything from
start to finish.
All
of the sample database files for this seminar are available on my Web site
(instructions on where to download them are in the course videos). They
are available in Access 2007, 2003, and 2000 formats.
Click here to download the sample database files.
This
seminar is available to view online in the Amicron Theater.
You can
click here to watch the first lesson absolutely free.
Of
course, if you have any questions about whether or not this seminar is
for you, please contact me.

Access Imaging Seminar Outline
0. Welcome (14:40)
1. Intro to Objects
(14:04) OLE Objects v. Images Bound v. Unbound OLE
Objects Linking v. Embedding When and when not to store objects Access
2007 Attachments
2. Database Setup (2:41) Creating
the Database
Customizing Options Trusted Locations
3. Table Form Setup
(5:41) Setup Employee Table Build Employee Form
4. Bound Embedded OLE
Objects (10:02) Insert Object Icons v. Full Images Edit or Display Object
Changing Registered Program Type Zoom, Clip, Stretch
5. Linked
OLE Objects (9:42) Linking to Objects File Folder Considerations Shared
Network Folders Editing Linked Copies
6. Non Image Objects
(6:55) Excel Spreadsheet Fragments Links to Word and Excel Files Employee Report
7. Unbound OLE Objects 1 (5:05) Shared Linked Excel
Sheet Editable
Sheet Stored in Form
8. Unbound OLE Objects 2 (8:56)
Main Menu Shared Logo on Forms Reports Editable Logo in Multiple Places
9. Image Control 1 (11:18) Inserting an Image Control
Manipulating the Picture Property Loading an Image from your Drive Change Image Button Loading
an Image when the Form Loads Empty Image Control Box
10. Image
Control 2 (12:00) Show Image on Bound Data Form Change Image for
Each Record in VBA Load Picture from Server or C: drive Creating Your Own Subroutine in
VB
11. Common Dialog Control (9:52) Up to Access 2003
Users Only Use CD Control to Pick a File Save Filename in Field Does Not Work in
Access 2007
12. Common Dialog DLL (9:08) All Versions
of Access Use DLL Call to Pick a File Works With ANY Version of Access Location of
Sample Database Files
13. Copy Files to Server 1 (8:22)
Create a SettingsT Table DLOOKUP Folder Path Change Display Code Null vs. Empty
14. Copy Files to Server 2 (11:25) Separate Filename
from Path GetFilenameOnly Function
15. Copy Files to Server 3
(12:34) Determine if File needs copying FileCopy command
16. Copy Files to Server 4 (9:17) Ask to Copy if File
Already Exists Dir Function Make EmployeeID
part of Filename
17. Handling Errors (9:13) Cancel on
Select File Picking a Non-Image File Type Image Files Moved or Renamed
18.
Editing Images (6:27) Creating Your Own Edit Event Shell Command
19. Embedding OLE with VBA (4:21) Pick a File Embed
the File in OLE with VBA code
20. Display Images from Web (10:53)
WebBrowser Control Determining an Images URL Navigate to a Web URL LoadPicture Subroutine
21. Attachments (10:57) Added in Access 2007
Attachments in Table Fields Pros and Cons Attachment in Form VBA to Work with Attachments
Count Attachments Cycle Through them on Form
22. Image Report
(5:22) Create a Report with Image Control
23. Review
(2:55)

|
|
| |
| |
Student Interaction:
Access Imaging Seminar
|
Richard on 1/1/2007:
Learn how to properly work with images and graphics in your database. This 3.5 hour seminar covers:
- OLE Objects, Linking, Embedding
- Display external images in forms
- Browse drive to select a file
- Copy to a "shared images" folder
- Embed non-image objects
- Display Web-based images
- New Attachment data type |
Rick R on 3/7/2010: IMPORTANT NOTICE: There is an even BETTER WAY to display an image on a form. Here's a link to a free addendum video that explains everything.
IMAGING SEMINAR ADDENDUM VIDEO
I discovered this AFTER I finished the seminar.
|
Richard on 3/7/2010: PLEASE NOTE: The web page for the sample database files and source code can be found in LESSON 12, about 1:41 into the video.
|
James on 3/8/2010: Great Class again Rick. Keep the VBA comming I love it. Great stuff here. I especially like the copy to server classes.
|
Dave Sterner on 3/9/2010: I am not seeing the time index you mention by at about 3 minutes when you drop the image control on the form it looks like there is a significant difference between Access 2007 and 2003. With my Access 2003, when I add the image control it automatically starts to browse for a picture and when I click cancel in the browse window, the image box gets deleted. To get an empty box, I had to load a picture and delete it from the picture property of the image control just like in the previous lesson.
|
Rupert Bennett on 3/9/2010: Hi Richard, I hit a snag while working through the Images Seminar. I am using Access 2003 and am tyring to use the Common Dialog DLL. I am not saving to a server, so I have my VB Code as EmployeePicture = (me, "C:\Program Files\Microsoft Office\Office11\Samples") I am getting the following error "Wrong number of arguments or invalid property assignment" Can you spot my mistake?
Thanks for your help. Rupert
Reply from Richard Rost:
Rupert, remember you're working with the picture PROPERTY of your image control. Change your code to:
EmployeePicture.PICTURE = (me, "C:\Program Files\Microsoft Office\Office11\Samples")
|
Dave Sterner on 3/9/2010: You might want to warn students about making the EmployeePicture field (the one that contains the path) text size larger than 50. I tried to load some jpg's from my MyDocuments\MyPictures folder and got an error message telling me my field was too small.
Reply from Richard Rost:
Thanks Dave. You just did. :)
|
Dave Sterner on 3/9/2010: Correction on my previous comment about cancelling out of the image object not being able to get an empty image box - I have Access 2002
Reply from Richard Rost:
Yep. I think I mentioned that in the video for 2003 and earlier users.
|
Rupert Bennett on 3/12/2010: At 08:25 in this lesson, we are comparing the length of the string in the Imagesfolder to determine if we need to copy up to the server. What if we are in another folder on the server, with the length of the PathFilename identical to that of the ImagesFolder? Would that not create a problem?
Reply from Richard Rost:
It's not just the length we're checking... we're comparing the beginning of the folder string to see if it's identical to the same length of string from the chosen file. I did think of one problem, however. If you have your Images folder set to:
C:\
Then any file you choose on the C:\ drive will show up as being in the Images folder for the purposes of this function. I suppose a better algorithm is needed. Until I have a few minutes to come up with one, just make sure your Images folder name is UNIQUE on your hard drive, like:
C:\Data\dbImages\
Or something like that - something that's not going to be easily confused with another folder.
|
Ray McCain on 5/6/2010: The image files which I am copying have been set up in multiple album amd sub-album folders, which I need to include in the complete pathfilename. How do I set up a mid string to identify everything between C:\Images\ and the filename and then be able to include it along with the pathname. It is also possible that no album name exists so I would need to check for an empty string and ignore it if one is found.
Reply from Richard Rost:
Hmmm... how about making "C:\images\" your root folder, and then just including any subfolder information either in another field, or as part of the image filename. You would then store your images relative to the root folder. For example:
joe.gif subfolder\sue.jpg another\subfolder\bill.gif
Would this work for you?
|
Alan Hill on 5/6/2010: The launchCD function is just what I have been looking for. It even opens up at the correct folder. That's great. I love it. Thankyou very much.
Reply from Richard Rost:
That's what you pay me for. :) LOL
|
Alan Hill on 5/6/2010: Hi Richard Common Dialog DLL I know the length of my filepath. N = Len(filepath): P = Len(FullPath) L = P-N so I used ImageTitle = Right(FullPath,L)to get the ImageTitle Seems to work OK Just about to watch copy files to server
Best wishes Alan Hill
Reply from Richard Rost:
Good approach.
|
Ray McCain on 5/21/2010: Due to the use of multiple folders to set up the albums needed for this photo directory, I need to retreive the entire path all the way to FileFolder which ends with "Images\". Since the backslash is in all likelihood not the last one in the path name, I need to know how to rewrite the mid or instr functions to accomidate this.
Reply from Richard Rost:
You can start from the end of the string containing the path/filename to isolate just the pathname. I would start a loop that looks for that last backslash. Let's say you have:
S = "C:\Users\Richard\Images\something.jpg"
X = len(S) While X > 0 and mid(S,X,1)<>"\" X = X - 1 Wend
Now you have the position of the last "\" in the string. At this point you can cut off the filename, which you can do with:
S = left(S,X)
Now you have just:
S = "C:\Users\Richard\Images\"
If you want to get what's BEFORE the Images\ folder, you can now just chop that off:
S = Left(S,Len(S)-7)
Since you know that "Images\" is 7 characters. Now you're left with:
S = "C:\Users\Richard\"
Hopefully this is what you're trying to find. Now, I haven't fully tested this (it's off the top of my head) and I didn't add any error handling (what if there are no \ in the string?) but it should get you started.
|
Lynn on 7/5/2010: So Far I have enjoyed the Access Imaging Seminar
|
Dan O'Neal on 12/17/2010: Richard, thanks for this seminar. I've got things working as needed by using code to target the needed images on a form and it works great on my computer, however, I need this to be portable. This is what I need....I'm using a variation between 5 different images on a form. Currently I point to the differing images using a separate button control to choose which image using VBA. AND it works great, but I'd like to store these images in the database without nessesarily storing each image in a record. Currently, if I use this database on another computer, the path is changed because of different users, so I need to include only five varying images within the database. I thought perhaps these 5 images could be stored in a table and changed by a control on the form, but after reviewing the seminar, just don't see how without imbedding each image into a record, therby inflating the database. How do I target a bitmap stored in a table (if this is even the right approach)Forgive me if this was covered in the seminar. Thanks in advance for any help. You da man!
Reply from Richard Rost:
If the images need to travel with the database, then yes, you should embed them in a table. It will inflate your database, but if that's what you've got to do for your solution, then that's what you gotta do. I did cover this in the seminar. It's not hard. You could just use one separate table for the images and then refer to them - you don't need a separate copy for each record in your main table. The only other solution would be to put them on a web server (if all of your users are online while using your database). Then you could just all point them to a URL for the images.
|
Rick on 1/8/2011: Richard,
I just finished lesson 15. My employee picture does move to the shared images folder, but the selected picture does not display on the form anymore.
Great job on this course!
Thanks, Rick
|
mohd bafgish on 5/14/2011: how i fix this problem please wihen i click cancel in commondialog dll in access 2007 show to me this message A file was not selected
and this code inside button commond
Private Sub Command11_Click()
sourceImage2 = LaunchCD(Me, "C:\Users\Bafgish\Desktop") updatepicture End Sub
Reply from Richard Rost:
You should just be able to say:
if SourceImage2="" or IsNull(SourceImage2) then msgbox "No image selected" exit sub end if
Put that right before your UpdatePicture line.
|
Gene Hightower on 7/9/2011: Richard, how to add multible images to a form and report?
|
Ellesha on 8/10/2011: Attachments Question
Hi Richard,
For access2003 Table DataType there is no Attachment. What should I do If I wanted to create a Attachment box which allow user to upload anykind (word. jpg. xcel attachment) to database?
Also, allow more than 1 attachment.
Thank you.
|
Alex Hedley on 8/12/2011: Hi Ellesha,
The Attachment is new to Access2007+ so you won't be able to do the same in 2003.
As Richard suggests in the Seminar you could just copy the file to a shared folder and save the file path in a field then open the file either with a Shell command or open the folder that it's to quickly find it.
Al
|
Lindray on 9/19/2011: I need help .... I made a form with a continuous subform where I put a vb code like this in the course of seminar image. the problem is that it shows the same image for every record, the right image shows only when I click on the record. the code is put into the subform as the rest of the code ..... This is the code
Private Sub Form_Current () Dim S As String
S = ImagesFolder S = S & Image
If Not IsNull (Image) And Image <> "" Then CustomerImage.Picture = S else CustomerImage.Picture = "" End If
End Sub
|
Ann Butler on 11/1/2011: I am getting message The operation on the OLE object failed. The OLE server may not be registered. To register the OLE server, reinstall it. ???
|
Jimmy on 12/29/2011: i have another way to get the file name without the path with this function:
Public Function FileNameNoExt(strPath As String) As String Dim strTemp As String strTemp = Mid$(strPath, InStrRev(strPath, "\") + 1) FileNameNoExt = Left$(strTemp, InStrRev(strTemp, ".") - 1) End Function
i get it from this web site http://www.vbaexpress.com/kb/getarticle.php?kb_id=767
|
eddy geijselaers on 2/20/2012: On lesson 11/12:
For those who installed AC 2007 or 2010 on their System using an older version of MS Office like me (XP), the "Common Dialog Control" works the same as in the older versions of AC.
Still the lesson 12 settings are better, as Rick explains, especialy if you want to distribute your DB later.
eddy peanut
|
eddy geijselaers on 2/23/2012: Lesson 9;10;11
The Common Dialog Control works nice, but, one minor thing to get around -- Since I didn't have a solution for my LaunchCD problem I tried the CD.
After canceling in the browser it still pick's the first file in the folder.
How to prevent this to happen?
eddy peanut
|
eddy geijselaers on 2/24/2012: Hi,
I've got it fixed, seems to be something that was upsetting my system-setting. Everything works fine now.
eddy
|
Silvano Natalizi on 3/23/2012: This seminar is very good. I wanto to develop an application in access 2010. This application must create a word document. I spent the full day studying, without a result, the libraries to check on tools-references, but i get always the same error for the instruction dim doc1 as Word.Application "user defined type not defined". What can i do? Thanks.
|
Silvano on 3/23/2012: I solved the first problem, i checked microsoft word 12.0 object library on references, but again stopped. Very easy: 1) dim doc1 as word.application 2) set doc1=CreateObject("Word.application") 3) doc1.visible=true 4) with doc1 .selection.typetext("paperone") end with --->run time error 91 object variable or with block variable not set ? Thanks for help.
|
Silvano on 3/23/2012: I solved the problem. I add the instruction : .Documents.Add before .selection.typetext("something")
|
Yolande Villeneuve on 5/23/2012: How do you do a server\SharedData\Images folder and link the table to the web site. I need that to be able to enter/or show the monuments in the original table
Please give me help ASAP as it is needed Presto.
Thanks for your support!
Reply from Richard Rost:
Hi Yolande. In this seminar, I really don't cover moving your images up to a WEB server. I just cover a normal FILE SERVER on your network. Uploading to a remote WEB server is a whole different ballgame. It's not super hard, but it involves some ASP programming.
Now, if your WEB SERVER is in your physical office and hooked up to your NETWORK (like one of mine is) then that's not a problem. Just set up the shared folder that you're using for your images on your WEB site. If you're using Microsoft Windows Server, you can do that in your IIS control panel (your IT person should know how). You can make any folder on your network a Virtual Folder in your web site.
If you have a web server in a DIFFERENT location (like hosted space on GoDaddy or some other ISP) then you'll have to upload the image files to that server. Setting up an AUTOMATED routine would take a good deal of programming. I could show you how, but it would probably have to be a separate seminar (at least a mini-seminar) in ASP.
If you upload the image files YOURSELF to the server using whatever web editor you have (FrontPage, Expression, etc.) then my Imaging Seminar DOES show you how to DISPLAY those images in your Access database (Lesson 20). But GETTING them there is the tricky part.
The Imaging Seminar is PRIMARILY for using Images WITH your ACCESS database - not a web site.
|
barry walt on 6/24/2012: Hi tryong to put a photo into my database form but it tells me (can't read the OLE because communication was interuped ) the photo and form are both on external drive thank you barry
Reply from Richard Rost:
Barry, this is very hard to diagnose remotely. Does your code with with a very small file? It could be just a problem with BIG files - perhaps your interface is too slow. Does it work off of an internal hard drive? Sometimes USB drives are problematic.
|
Sam Vodoor on 7/15/2012: Can Access display a Vector file image?
Reply from Richard Rost:
Not by itself, however if you have a program installed like CorelDraw or Illustrator you could store the image files from those apps as an OLE object and they would open up with a double-click. I don't recommend it though. Best to keep them external files with a link.
|
Dan on 10/15/2012: Hi Richard,
Great tutorials!
I am having a problem though. In video 12 at 7:00 minutes you discuss the code for the image button. However, my image button causes an error with the "LaunchCD". It works ok if I follow it with just "Me". If I add the optional path to begin looking, I receive the error "Wrong Number of Arguments or Invalid Property Assignment." I'm not sure what I'm doing wrong. I followed you tutorial to a "T". I'm using Access 2003.
Thanks,
|
Phil on 10/15/2012: My version is not copying correctly.
1) The path of the ImagesFolder is correct M:\Human Resources\HRIS\HRIMS_EmployeePhotos\
However, the File Employee Picture [File Name Returned] is not correct
It is HRIMS_EmployeePhotosEmployeeName.jpg
It should be EmployeeName.jpg
Also, it is copying to the wrong directory -
it copies to M:\Human Resources\HRIS
It should copy to M:\Human Resources\HRIS\HRIMS_EmployeePhotos\
Can you help?
Reply from Richard Rost:
I would need to see your database to tell you exactly what the problem is. I'm sure it's probably an incorrect or misspelled variable name or something similar.
|
Dan on 10/16/2012: I did some trial and error and was able to make it work.
Private Sub Command7_Click()
Dim PathFilename As String Dim FilenameOnly As String Dim L As Integer L = Len(ImagesFolder) PathFilename = GetFileNameOnly(LaunchCD(Me)) FilenameOnly = PathFilename If Left(PathFilename, L) <> ImagesFolder Then 'FilenameOnly = EmployeeID & "-" & FilenameOnly To Add claim number to photo. If Dir(ImagesFolder & FilenameOnly) <> "" Then If MsgBox("File Already Exist, Overwrite It?", vbYesNo) = vbNo Then Exit Sub End If End If FileCopy PathFilename, ImagesFolder & FilenameOnly End If Me.EmployeePicture = FilenameOnly UpdatePicture End Sub
|
Phil on 11/9/2012: I am having a problem with the Images Seminar. I followed all the instructions and my database worked fine. Pictures uploaded and copied to the server file as designed. However, when I followed the instructions in the 2007 addendum that told me to delete all code my picture loads to the database but it no longer copies to the server file. The table just stores the address of wherever the picture was selected. I still want the images to copy to the server.
Reply from Richard Rost:
This is one of those things where it's almost impossible for me to help you without seeing your setup. If it worked before, it sounds like you might have accidentally deleted too much? Try recreating the code again and see where the problem is. Without walking you through EVERY STEP, I can't tell what happened from here.
|
Ricardo Tolliver on 2/18/2013: I got the image control to work on a form but not on a report. I need to be able to print the image and information, which is better to use for print individual record information.
Reply from Richard Rost:
It should work - it's basically the same control. I'd need to probably see your database to tell you what the problem is... but whenever you want to PRINT something, you should use a report.
|
Ajantha Rathnayake on 3/2/2013: Richard, can a report display a web image? if so how? I tried webbrowser control in report and it didn't work. Please help. Thanks Indu
Reply from Richard Rost:
You cannot put a Web Browser Control in a Report or a Continuous Form. I don't know of any way to display a live web image in a report. You would need to download the image locally and then display it.
|
|
|
| |
|
You may want to read these articles from the 599CD News: |
|
|
|