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
alevin16Asked:
Who is Participating?
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???

ET
0
Dale FyeCommented:
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"
        else
            me.bookmark = .bookmark
        end if
    End With

End Sub

Open in new window

0
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

Thanks
Andy
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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*
ex:
    C:\YourFolder\YourImage.jpg

So your listbox bound column must display this stored path.
So on the AfterUpdate Event of the listbox, ...you would do something like this:
    Me.YourImageControl.Picture=Me.YourListbox

JeffCoachman
0

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.

Andy
0
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


JeffCoachman
Database90-2.accdb
1
alevin16Author Commented:
Thank you so much Jeff!  I am going to try that right now.  Love the picture of the dog and cat :D
0
alevin16Author Commented:
Hello Jeff

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

Thanks
0
Jeffrey CoachmanMIS LiasonCommented:
Not sure I understand what you mean.
All attachment fields are bound to the attachment...
0
alevin16Author Commented:
Sorry I meant that the form itself is not bound to an underlying table.
0
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...
0
Martin LissOlder than dirtCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.