Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-09-30
8
Medium Priority
?
467 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
  • 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 400 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

927 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