Solved

How can I add a bitmap to an Access database using VB5 or VBA?

Posted on 1998-09-30
8
457 Views
Last Modified: 2008-02-26
I am currently having a problem getting a bitmap image into Access without having to edit the data, click the field, selecting "Insert Object..." then creating an object from file. I have a VB5 application that currently writes the bitmap to the database field but it gets stored as "Long binary data" instead of "Bitmap Image". I am using Crystal Reports 6 to do my reporting and it insists on bitmap images. The "Long binary data" format is no use. Is there anyway in VB5 or VBA to take a bitmap image and save it into the OLE object field retaining the "Bitmap Image" format, not the "Long binary data" format? Thanks in advance.
0
Comment
Question by:imajdn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 3

Expert Comment

by:tcurtin
ID: 1963856
Hi imajdn,
Have you tried writing the bitmap image to the database 'as object'. Where is the file coming from?
0
 

Author Comment

by:imajdn
ID: 1963857
tcurtin,
   when you say writing the image as an object, how do you propose to do this in VB5?

The file is stored on my hard disk or on a server. I load it into my VB5 app using LoadPicture to set the picture property of an image control. The image control is connected to a data control which in turn is connected to the database field. When I load the image in it is automatically saved to the database.

Cheers.

0
 
LVL 2

Accepted Solution

by:
Belz earned 200 total points
ID: 1963858
Instead of setting the image directly into the table in the MDB, use the clip board.  Can you set the focus to the object in your VBA code then send the keys to copy it into the clipboard then set the focus to the table field and do a paste.  the clipboard will keep the native BMP formatting.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:imajdn
ID: 1963859
Hi Belz,
   you have lost me. If this can be done then please show me how as I'm not sure I know
what to do. I am currently working on something else at the moment and have had to shelve this for the moment. If you can show me the code to do this then I'll give you the points but I don't have the time to explore copying/pasting to/from the clipboard to the database. I know the syntax is something like object.Copy and object.Paste but I don't know how to combine this with an Access 97 database. Thanks in advance.

0
 
LVL 2

Expert Comment

by:Belz
ID: 1963860
I'm not 100% sure how your creating your bitmap in VB5.  Is it written to the harddrive, displayed on the screen, or in memory as an object.


0
 

Author Comment

by:imajdn
ID: 1963861
Hi Belz,
   the bitmaps are either files on my hard disk or I load them into an image control using LoadPicture to set the picture property.

Cheers.
0
 
LVL 2

Expert Comment

by:Belz
ID: 1963862
Here's what I just setup and ran and it works

FORM:
2 command buttons - Copy BMP and a Reset
2 Text Boxes - Test1 and Test2
2 Unbound Objects - Test1 and Test2
1 option set with 2 options - one for direct set of BMP and the second to use the clipboard.

TABLE:
1 Table - 2 Fields - Test1 (Ole Object), Test 2(Ole Object)
Manually paste a BMP into Test1.

CODE:
Option Compare Database
Option Explicit

Private Sub cmdCopy_BMP_Click()
       
    Select Case optMethod
    Case 1 ' Direct Setting of BMP
        Me.obdTest2 = Me.obdTest1
        DoEvents
    Case 2 ' Copy / Paste of BMP
        Me.obdTest1.SetFocus
        DoCmd.RunCommand acCmdCopy
        Me.obdTest2.SetFocus
        DoCmd.RunCommand acCmdPaste
    End Select
    Me.Requery
   
End Sub

Private Sub cmdReset_Click()

     Me.obdTest2 = Null
     
End Sub

0
 
LVL 2

Expert Comment

by:Belz
ID: 1963863
I forgot to tell you that you can also do the same thing with the text boxes instead of the unbound object frame.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question