Picture in database (no database bloat)

David Boyd 1 Reputation point
2021-03-08T13:09:24.31+00:00

I have a database where the file location of passport pictures (JPG) has been entered. A picture box then displays the picture. This worked just fine. Then I had to re-install Office 64 bits after uninstalling Office 2016 64 bits.' Now the picture no longer displays. The location & filename string is still there, just nothing displays. Somebody else made this for me and he is no longer available top ask how he did that. All I can tell is that there is nothing in Properties to indicate what "fills the picture box". I found online that it is probably a bit of VBA that used to fill the picture box. Great, I know nothing about VBA. I did find a macro that has apparently been misnamed, that deals with pictures, but I have no clue how it is called upon, or what actually fills the box. At the moment, nothing fills the box; it is empty. The database has not changed. I even restored a backup of the database to make sure, and even backups don't fill the picture box. Can somebody explain in easy to understand language what I need to check or fix or change? It almost seems like a setting, but I have no clue what setting?

David

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
852 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Ken Sheridan 2,756 Reputation points
    2021-03-09T14:50:18.047+00:00

    Does your reference 'location & filename' mean there is a column (field) of text data type in the table on which the form is based which stores the path to an external image file? If so the control is probably an Image control, in which case its ControlSource property should be set to the name of the text column. This will load the image into the control at runtime.

    In earlier versions of Access an Image control did not have a ControlSource property, and it was necessary to assign the path to the Image control's Picture property when the form moved to a record. It could be that the macro to which you refer is called as the form's On Current event property to do this, so check this out. If so you'd be able to delete the setting for the event property and use the Image control's ControlSource property instead.

    0 comments No comments

  2. Ken Sheridan 2,756 Reputation points
    2021-03-17T15:39:54.093+00:00

    I'd suggest that you take a look at Images.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Take a look first at Images_Simple.accdb in the zip archive. This illustrates the use of an Image control to display a single image on a bound form. The ControlSource property of the control is ImagePath, which is the name of a column (field) in the Addresses table to which the form is bound.

    No code is required to display the image per se, but code in the form's Current event procedure does hide the image control if its ControlSource property is Null, and displays a 'No Image' label instead.

    The Images_Simple file should give you an appropriate model to follow for what you are attempting. For more complex image handling you might like take a look at the other files in the zip archive later.

    0 comments No comments

  3. David Boyd 1 Reputation point
    2021-03-17T14:59:23.617+00:00

    Ken,

    Thanks for your response. Unfortunately, though I am bilingual, my Windows Computer and Office installation is not. It is Dutch. So I am somewhat at a loss to find things like "Image Control" and "Control Source Property". Here is a screen shot of the affected area of my Form:
    78769-knipsel.jpg
    I have copied and pasted the text in the Pasfoto field's Besturingselementbron (which I assume is Control Source Propert) i.e. "txtNaamFoto" into the Besturingselementbron of the 3x4 rectangle where the picture has always appeared before (selected so therefore there is an orange box around it).
    When I go back and Display the Form, there is no picture.
    The error that is displayed when I click on the exclamation point shield is (my translation):
    "Invalid property of the Control Element: Control element source (Besturingselementbron)" / "That field does not exist in the list of fields". When I check the list of fields, sure enough txtNaamFoto is not there. I am so confused!

    I have noticed however, that this field where the picture is supposed to display has a white border around it when the picture is actually located in the path designated in the text field. If that picture does not exist, then there is no white border in that blue field. So it seems to be recognizing that something is there, but isn't processing it correctly.

    I have learned, that when a person uses the Word "before" in describing a problem it is often useful to describe what changed. "Before" I used Office 2019 on a different computer. That computer died. I went back to an old Computer that already had Office 2016 installed, and the picture worked. I purchased a new laptop and installed Office 2016 64 bits. It did not work correctly with Mailmerge Word to Outlook, so I completely uninstalled it and installed Office 2016 32 bits. That solved the Mailmerge problem. I believe my problem with the pictures in Access started either with the new computer or with the intallation of the 32 bits version of Office 2016.

    Furthermore, here is a screenshot of the Macro I think is responsible for retrieving the picture when a record is accessed. I was told by the person who made this for me, that this was the way to avoid database bloat, where the pics end up being stored in the database file. He said, this loads in only the picture of the record being shown.

    Option Compare Database
    Option Explicit

    Private Sub Form_Current()
    On Error Resume Next

    If FileExist(Me!txtNaamFoto & "") And _  
        Len(Me!txtNaamFoto & "") > 0 Then  
        Pasfoto.Picture = Me.txtNaamFoto  
        Pasfoto.Visible = True  
    Else  
        Pasfoto.Visible = False  
    End If  
        
    

    End Sub

    -----------------------------------

    For reasons I cannot fathom, this site's editor numbers each of the lines of the VBA that I tried to paste. They are obviously not present in the macro.

    Again, I know very little about all the ins and outs of Access and have next to no knowledge of VBA. Since I don't have an English version of Access, you can destroy the effectiveness of you answer with an English term that does not correspond to anything I see in Dutch. So please, simple, step by step (i.e. "third row from the top") instructions on how to fix this. Thanks. I have tried asking these types of Question on the Dutch site, but they usually tell me my question if too complicated and that I should ask it here or on the Developer's forum.

    David

    0 comments No comments