Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2005, 11:04 PM
Authorized User
 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Importing a bitmap to an ole field

Hey,

I'm having trouble adding a bitmap file to an ole object field in my table.

Here's the problem....

I have a folder with a couple of hunderd bitmaps in them. What I need to do is to add these files into a table with their associated file name. I don't want to just link to files.

The table looks like

PhotoID (Autonumber, Primary Key)
PhotoName (String, The file name)
Photo (OLE Object, The actual photo)

I can loop through the files in the folder and get the PhotoName, no problem. But when I try to add the Photo to the ole field, it adds it in as "Long Binary Data", instead of a "Bitmap Image".

Does anyone know how to force the recordset into adding the data as a "Bitmap Image" (setting attributes somewhere??), or is there another way of doing this?

Here's a portion of the code I'm using:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim oFS As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File

    Set db = CurrentDb()

    Set rs = db.OpenRecordset("IMAP_tblPhoto")

    Set oFolder = oFS.GetFolder("C:\Photos")

    With rs

        For Each oFile In oFolder.Files

            .AddNew
            !PhotoName = oFile.Name
            !Photo = oFile
            .Update

        Next oFile

    End With

Thanks for any help!!

Cheers

Rohan
__________________
Cheers

Rohan
 
Old February 10th, 2005, 11:31 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Rohan,

try setting !photo.sourcedoc to ofile

Kevin

 
Old February 11th, 2005, 12:25 AM
Authorized User
 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin,

Thanks for that, but no cigar!!

The sourcedoc property is not valid for recordsets, but for bound and unbound controls.

I am not sure how to tell the field to expect a "Bitmap Image". Whenever you insert data into the table directly, it always asks what type of data is to be expected (ie Bitmap, Excel Worksheet, Word Doc etc...) I am not sure how to pass this information to the recordset? You would think that it should automatically recognise what type of object I'm trying to pass it.

Any other ideas??

Cheers

Rohan
 
Old February 11th, 2005, 12:37 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Rohan,
What about insert instead of update?

I don't use recordsets. I usually create a form based on my table and create code to step thru the records.

Sorry I couldn't help.

Kevin

 
Old February 11th, 2005, 08:15 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The only way I know on how to inport images like this without using the built in dialog is through File I/O with BLOBs (binary long objects). you may find this link useful.

 http://support.microsoft.com/support.../q103/2/57.asp

hth

Jon
 
Old February 11th, 2005, 08:30 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just found this site that has a sample database for you to examine. It should help you with your mission!!

http://accdevel.tripod.com

Jon
 
Old February 13th, 2005, 11:57 PM
Authorized User
 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey guys,

Thanks for your help.

I'll try your suggestions and checkout the links.

Cheers

Rohan





Similar Threads
Thread Thread Starter Forum Replies Last Post
Double-click on OLE field - SOLVED Tachyophan Access 0 August 16th, 2006 03:06 AM
inserting worksheet into an OLE field with VBA Mihai B Excel VBA 2 January 21st, 2005 06:50 AM
Inserting worksheet into OLE field Mihai B Access 0 November 24th, 2004 07:39 AM
inserting worksheet into an OLE field with VBA Mihai B Access VBA 0 November 23rd, 2004 10:28 AM
Displaying OLE object field in a form Rick Neifeld Access VBA 0 December 24th, 2003 02:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.