Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Adding pictures to a database (2003 sp2)

    I am curious as to how one would add pictures to a database through a form, assuming the pictures would be added one at a time. Copy and paste the picture file into the field? I may be faced with doing this soon.
    Thanks
    chuck

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding pictures to a database (2003 sp2)

    In Access 2003 and before, it is not a good idea to store images in a database - it causes the size of the database to balloon. The preferred way is to store the path and filename of an image file in a text field, and to use code to display the images in an unbound Image control.

    See the attachment to <post#=296892>post 296892</post#> for an example of how to handle images.

  3. #3
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding pictures to a database (2003 sp2)

    Hans, I have been working with the database you attached to post 296892, (haven't got it working in my app yet) and I've noticed that the status bar shows a reference to the file path stored in tblInventory. If I close the database but not Access and open another database from the container window, the status bar still holds the reference to the file path. Does this indicate something running in the backround?
    Thanks
    chuck

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding pictures to a database (2003 sp2)

    No, it just means that I forgot to add a line of code to clear the status bar when the form is closed. Access leaves the status bar alone once it has been set using code, until it is cleared again.

    If you add the following event procediure to frmInventory, the status bar will be cleared when the form is closed:

    Private Sub Form_Close()
    SysCmd acSysCmdClearStatus
    End Sub

  5. #5
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding pictures to a database (2003 sp2)

    On frmInventory the text box used to hold the image is named imgPicture, but on the report it is named txtCover. Then in the code in the OnFormat of the Detail section of the report you refer to imgPicture but not to txtCover. Please explain.
    Thanks
    chuck

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding pictures to a database (2003 sp2)

    The control used to display the picture is not a text box but an image control (text boxes can only be used to display text, not images). The image control is named imgPicture on both the form and on the report, and the code for both refers to imgPicture.

    I use a trick on the report. If no image is available for a record, I would like to reclaim the space taken up by the image control. But unlike text boxes, image controls do not have a Can Shrink property. Even if I hide the Image control if no picture is available, it'll still take up space on the report. To work around this, I have placed a text box txtCover over the image control, precisely covering it (hence the name). The Can Shrink property of the text box is set to Yes. This technique is from MSKB article ACC: How to Make Empty or Null OLE Object Not Appear on Report.

  7. #7
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding pictures to a database (2003 sp2)

    Hans, I have succeeded in adapting your little add pictures app to my needs thanks to the help of your explanations, (and of course the app itself). The picture is inserted into an inspection form and then converted to a PDF file thanks to Steven Leban. In the past pictures were sent seperately via email and really took up a lot of email space. Now, the resulting PDF file is around 15% of the picture size alone. What a great help this will be.

    Many thanks to Woody's Lounge and the great people who share their expertise there.
    Thanks
    chuck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •