Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-09-30
8
Medium Priority
?
462 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 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

670 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