How to Access Long Binary Data

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Access Long Binary Data
Export images from an Access database table with VBA. (binary flood image by Attila Toro from

Knowing how to access long binary data from a database table can make your database application more dynamic. Microsoft Office Access is commonly used to design local databases. Long binary data is used to store image files in a database table. You can use Visual Basic for Applications (VBA) to export the binary data to a file. VBA is a computer programming language used to automate routine tasks in Access and other Office applications.

Skill level:

Other People Are Reading


  1. 1

    Open Microsoft Office Access; select the "Create" tab and select "Form Design" to create a new form. Right-click the form to display the "Property Sheet."

  2. 2

    Click the "Data" tab. Next to "Source Object," type the name of the table containing the long binary data. Select "Form" under "Selection type." Click the "Event" tab and next to "On Click" select "[Event Procedure]" to open the Microsoft Visual Basic Window.

  3. 3

    Type the following under "Form_Load" to call the function to extract long binary data from your table to a file:

    imageToFile "C:\Images\exportedImage.jpg", [Image]

    Edit the path if you want the image to be exported to another path and a different file name. "[Image]" is the field in your table containing the long binary data.

  4. 4

    Copy and paste the following function into your module:

    Public Function imageToFile(strFile As String, ByRef Field As Object) As Long

    Dim file Number As Integer
    Dim byte Data() As Byte
    imageToFile = 0
    file Number = FreeFile
    Open strFile For Binary Access Write As file Number
    byte Data = Field
    Put #file Number, , byte Data
    imageToFile = LOF(fileNumber)

    End Function

  5. 5

    Close the "Microsoft Visual Basic" Window and right-click "Form1." Select "Form View" to export the binary data and create an image file.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.