Image of Navigational Panel mapped to Contents / Home / Search Access OLE Fields
Tech Support Question

Image of Line Break

Q. I have found a few routines that help me to display a PaintBrush BMP stored in an Access OLE field, but I would like to know if there are any utilities out there for storing these pictures in an Access field, and for support of other graphic data types?

Thank You.
From: Steve Mansfield
Email: syberdyn@iglou.com
Organization: Syberdyne Systems

A. Steve, the easiest way to write BMP files into an Access OLE field is to write a tiny VB app. All you need is a form with the following controls:

  • A Picture control (Picture1)
  • A Data Control (Data1)
  • A Command Button (Command1)
  • A Common Dialog Control (CMDialog1)
  • Set the DatabaseName and RecordSource properties of the data control to the database and table containing the OLE field that you wish to write bitmaps into. Set the DataField property of the picture control to point to the OLE field. Set the filter property of the Common Dialog control to "BMP Files|*.BMP". You should also add a few labels that are bound to some other fields in the table so that you can see which record you are currently viewing. Now, add the following code to the command button Click event:

      CMDialog1.Filename = ""
      CMDialog1.Action = 1
      If CMDialog1.Filename <> "" Then
      Picture1.Picture = LoadPicture(CMDialog1.Filename)
      End If
    

    This will allow you to click the button for any given record and browse for a bitmap file. It then uses the LoadPicture function to set the selected picture into the picture property of the picture box. Because the picture box is bound this automatically writes that picture to the database whenever you move onto another record.

    This is a quick and dirty way to write bitmap files into the Access database. You can add some error checking and a pile more functionality, but that should get you started. There are a number of third party custom controls available for displaying other graphic formats that also support this sort of binding. You might want to consider "ImageMan/VB" by Data Techniques (as advertised in The GUI Computing Catalogue) or "ImageKnife" by Media Architects.

    Happy coding.


    Image of Arrow to Previous Article Image of Arrow to Next Article

    [TECH SUPPORT TOC]
    Image of Line Break
    [HOME] [TABLE OF CONTENTS] [SEARCH]