Results 1 to 5 of 5
  1. #1
    JPPoulin is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2016
    Posts
    3

    How to insert images via SQL that are visible in Access forms...

    Hello (awesome) Access gurus!

    I have a need to insert images into Access via plain SQL. My objective is to use a statement like "INSERT INTO Images(MyImageField) VALUES(0x12345678)" where 0x12345678 is replaced by the long hex sequence that contains the binary representation of the PNG or BMP image I want Access to store and view.

    A statement like the above works fine to store binary data of any size into the field but I want Access to properly render the image I insert into forms.

    I know Access can render images if I choose OLE data as my field type and insert OLE objects but its likely that I could not generate the binary representation of that in code the way I can generate a valid PNG or BMP image from C code.

    Is this possible?

    Thanks for your advice and time!

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Access doesn't handle some image types at all, and others not so well. The usual approach is to have a table of image links and another field to tie the image to something else (such as an employee id related to the link for that employee image). The images are stored in a local or network drive folder. The image control can load the correct image based on the related link for a record. The main reason for this is that an Access database can soon become overly large and easily corrupted, even if the images are not all that large.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    JPPoulin is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2016
    Posts
    3
    Quote Originally Posted by Micron View Post
    Access doesn't handle some image types at all, and others not so well. The usual approach is to have a table of image links and another field to tie the image to something else (such as an employee id related to the link for that employee image). The images are stored in a local or network drive folder. The image control can load the correct image based on the related link for a record. The main reason for this is that an Access database can soon become overly large and easily corrupted, even if the images are not all that large.
    Hi Micron, I agree that storing the images outside Access and linking would be better, but in this case hope to present the client with a single file for portability reasons. Have you found a way to insert images that Access can display directly with INSERT INTO statements?

    Thanks for taking the time

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    SQL commands like INSERT INTO are, I'm quite sure, reserved for data, not attachments or files, so I think not but have to say I've never tried.

  5. #5
    JPPoulin is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2016
    Posts
    3
    Hi Micron, thanks for your effort.

    The idea was to place exactly the bytes of a well-formed BMP or PNG image into that field to see if Access could draw it. I guess I could insert a BMP file containing a know image pattern that Access could render, extract the bytes and try to reverse-engineer how to insert any image by reversing the process.

    Just asking if someone has done this before

Please reply to this thread with any new information or opinions.

Similar Threads

  1. My Images Aren't Visible
    By hjmorgan in forum Reports
    Replies: 6
    Last Post: 11-06-2015, 10:54 AM
  2. Replies: 3
    Last Post: 11-24-2014, 11:09 AM
  3. Replies: 5
    Last Post: 10-07-2014, 09:20 AM
  4. Access 2010 - Images on Forms
    By dluhop in forum Forms
    Replies: 23
    Last Post: 10-05-2011, 08:51 AM
  5. Replies: 2
    Last Post: 01-06-2011, 04:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums