How can I get a bound object frame to show on a form in Access when my users choose a record from a listbox

Hello All

I now have a new issue with my images in an Access database.  I have a bound object frame control on a form.  The user fills out the form and then copy and pastes the image into the bound object form.  At this point all is well and good.  They can see it and when they save the record and view or print the image is appearing on the report like I wanted.

Here is the issue.  WHen the user selects that record again from a listbox of all records, I cannot get the bound object control to show the image that is stored in the database.

The owner of the company demands that the images (chart images taken from an excel spreadsheet) be stored in the database and not have the database simply link to the location of the original file.

I have tried the value property as well as a few others but it does not seem to want to show the image when the user is running the form.

Any ideas?

Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eric ShermanAccountant/DeveloperCommented:
Can you use the Form's OnCurrent Event to refresh the bound object frame with the correct image for that record???

Dale FyeOwner, Developing Solutions LLCCommented:
If selecting a record in the listbox is not actually moving the record pointer to the associated record, it is not going to do anything for you.

You might want to do something in the Click event of the listbox, something like:
Private Sub lst_YourListName_Click

    Dim strCriteria as string

    strCriteria = "[ID] = " & me.lst_YourListName

    With me.recordsetclone
        .findfirst strCriteria
        if .nomatch then
            msgbox "record not found"
            me.bookmark = .bookmark
        end if
    End With

End Sub

Open in new window

alevin16Author Commented:
Hey Guys

Here is the code I was using

    oleAttachedImage.Value = lstDicingInProcessGreen.Column(30, (lstDicingInProcessGreen.ListIndex))

When I use listindex for all the other types of fields it brings back the correct value.  Do ole objects work differently when I try to retrieve them?

I am not a very accomplished Access Programmer, I know enough to be dangerous and basically get the job done and believe it or not I never used recordset

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Jeffrey CoachmanMIS LiasonCommented:
If I am understanding your request correctly...

Instead of a bound object frame, use an "Image" control to display images in a Report or Form.
ImageThen note that you must store the *Full Path and file name*

So your listbox bound column must display this stored path.
So on the AfterUpdate Event of the listbox, would do something like this:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alevin16Author Commented:
Hello Jeff

The owner does not want me to store the image in another area with a link to it (I wish I could, I think it would be a lot easier).

He wants the image to be stored in the table with the rest of the data.

Jeffrey CoachmanMIS LiasonCommented:
OK, then just use the attachment datatype.
To do this your db must be in the .accdb format

Create the new attachment field in the table, (name it "ImgAtt"), and double-click it to "add" your images to the field (stored IN the database)

Then you must create a query to reference this field (the listbox wizard will not recognize the attachment field.)
Something like this:
SELECT ID, ImgAtt.FileName
FROM YourTable;
Then set this as the rowsource of the listbox

Then create a form based on the table, ...but only include the ID field and the ImgAtt.FileName field.

Code on the afterupdate event of the listbox will be:
Private Sub List0_AfterUpdate()
'Move to the currently selected record in the listbox
Dim rs As Object
Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID]= " & Me.List0
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Open in new window

On the current event of the form do:
Private Sub Form_Current()
'sync the listbox to the form record
Me.List0 = Me.ID
End Sub

Open in new window

Then use the report wizard to create the Report normally (including the ImgAtt field) and the image will display automatically

Note that if you use the attachment datatype and you drop this field on the report/form, ...the image will display normally (you don't have to muck around with creating bound/unbound controls)

sample db is attached

alevin16Author Commented:
Thank you so much Jeff!  I am going to try that right now.  Love the picture of the dog and cat :D
alevin16Author Commented:
Hello Jeff

I realized I forgot to mention that the attachment field on the form is unbound.  Will that cause a problem?

Jeffrey CoachmanMIS LiasonCommented:
Not sure I understand what you mean.
All attachment fields are bound to the attachment...
alevin16Author Commented:
Sorry I meant that the form itself is not bound to an underlying table.
Jeffrey CoachmanMIS LiasonCommented:
So why not just bind it?
Then all this works beautifully.

In other words, ...what the issue if it is bound...?
You dontt need to show any fields, ...the binding is only behind the scenes...
Martin LissOlder than dirtCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.