Results 1 to 12 of 12
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Image Display (WXP Access 2002)

    I've duplicated the diplay image code in the Northwind sample Employee form and it works just the same with one exception. In the Northwind sample after selecting a new picture it appears right away. In my application it doesn't appear until I exit the record and then reenter it. As far as I can tell I have exactly the same code and setup as in Northwind, but I can't get the image to display immediately after selecting a new one.

    Any suggestions?

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Image Display (WXP Access 2002)

    Chuck

    Can I ask, which event on your form, does the Image code reside.
    Usually to display images on the fly, the On_Current event is the best place.

  3. #3
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Image Display (WXP Access 2002)

    Initially the record comes up and the On Current event causes the image to display. However, I have two other controls regarding the image on that form. One removes the image by erasing the image file name in a "Photo" field in the record. The other is the Add/Change command that inserts a new image file name into the record. My problem is when I click on the add/change image. it brings up a dialog box letting me select an image to be displayed. However, the image doesn't immediately get displayed. It stays blank until I go to another record and then return to the original record. Then the new image shows up.

    I believe what I need is a way to re-trigger the On Current event that displays the image. It doesn't get triggered when I change the image because I'm not re-entering the record. When I exit the record and return, then it displays.

    It seems to me that there ought to be a command that I can tack onto the end of the Add/Change subroutine that re-loads the record and thereby re-triggers the On Current event, or perhaps there is another type of event that could be triggered to do the same.

    What's really bothersome is that it works perfectly in the Northwind sample database, but not in my program, and I have faithfully copied the code to implement the exact same function. I must be missing something.

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Image Display (WXP Access 2002)

    Chuck

    I've had a look at the Northwind example this morning but, not knowing your scenario in detail makes things difficult.
    I understand what you say with calling the On_Current event but feel this is something else.
    When you remove the pic, I assume you are setting the .Picture proerty to "", ie

    Me.MyImageControl.Picture = ""

    Then you probably need to save the record and requery, repaint or refresh the form.
    If you requery, your record will probably change to the most recent one, which causes a problem if you are half way thru the recordset.

    If you can create a demo under 100k zipped, I'll gladly take a look for you .

  5. #5
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Image Display (WXP Access 2002)

    Hi Dave,

    You are right in that the picture removal code simply replaces the Photo field in the table with a null string. The Add/Change code calls up a file open dialog box and puts the selected picture filename into the Photo field in the table. I think what should happen after that is a call to repeat the OnCurrent code which contains the commands that cause the display of the picture.

    I don't think my application will fit under 100K, but it exactly duplicates the one in the Northwind sample -- I literally copied the code across!

    Thanks for your input.

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Image Display (WXP Access 2002)

    Chuck
    You shouldn't have to re-trigger the On_Current Event at all.
    What references do you have set, and can you post the on current event code so we can take a look.
    Paste into a word or Text doc any info you feel may be appropiate.

    I was using the incorrect version of Northwind so I was puzzled I had no code behind the form.
    Here's all the code behind my form for you to compare just in case something is amiss:
    Attached Files Attached Files

  7. #7
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Image Display (WXP Access 2002)

    Hi Dave,

    That looks like exactly the same code I'm using except that in the Sub Form_AfterUpdate() I have omitted the "Me!ReportsTo.Requery" because I don't have a ReportsTo field in the table.

    The only other significant difference I have found so far is in the Image Frame Properties. The first property under "Format" is "Picture." In my application this property is set to the filespec for the image that is being displayed. However, in the Northwind Employee properties it has "(none)" -- even so the Employee picture displays OK, and I don't understand this either

    I'm attaching my code in WordPad format.

    .

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

    Re: Image Display (WXP Access 2002)

    The Picture property of the ImageFrame control is set in several places in trhe code - in the On Current event of the form, in the After Update event of the form and of the ImagePath control. So even if there is no picture in design view, it will be set as soon as the form is opened.

    I fear that we won't be able to solve this from a distance. Dave asked you to post the database; you don't need to post it in its entirety, just the parts having to do with this form will do:
    <UL><LI>Make a copy of the database and work with that.
    <LI>Remove all database objects (tables, queries, forms, reports, macros and modules) that are not relevant to the problem.
    <LI>In the remaining table(s), remove most records - leave only the minimum number necessary to demonstrate the problem.
    <LI>Remove or modify data of a confidential nature.
    <LI>Do a compact and repair (Tools/Database Utilities).
    <LI>Make a zip file containing the database; it should be below 100KB.
    <LI>Attach the zip file to a reply.[/list]Oh, and set the Picture property of ImageFrame to (none) in the copy; this may help reducing the size.

  9. #9
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Image Display (WXP Access 2002)

    OK Hans,

    Attached is the data base. On my computer it works like this:

    When I click on Remove the picture goes away.
    When I click on Add/Change I get a dialog box for selecting the picture. That works OK, BUT the picture doesn't display until I exit that record and then re-enter that record.

    That's not how it works in the Northwind sample. The new pic shows up immediately upon selecting a new one.

    Any suggestions are more than welcome.

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

    Re: Image Display (WXP Access 2002)

    Chuck,

    The code you attached to <post#=309410>post 309410</post#> contains an essential part that is lacking in the database you posted: the After Update event procedure for the ImagePath text box. The getFileName procedure contains a sneaky trick to make the picture update, but it depends on the missing bit of code: it sets the focus to ImagePath, fills in the name of the file selected by the user, and then sets focus to FName. since the contents of ImagePath has been changed, this causes the After Update event of ImagePath to be fired. In the Northwind database and in the code you posted earlier, the After Update event procedure sets the Picture property of ImageFrame to ImagePath:

    Private Sub ImagePath_AfterUpdate()
    ' After selecting an image for the employee, display it.
    On Error Resume Next
    showErrorMessage
    showImageFrame
    If (IsRelative(Me!ImagePath) = True) Then
    Me![ImageFrame].Picture = path & Me![ImagePath]
    Else
    Me![ImageFrame].Picture = Me![ImagePath]
    End If
    End Sub

    but as I mentioned, this code is not in your database. Therefore, the picture is only shown when you move to another record and back; then, it is the On Current event of the form that sets the Picture property.

  11. #11
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Image Display (WXP Access 2002)

    Dear Hans,

    You are a real saviour! That made it work. What really bugs me is that I originally had that code in my application -- I had even printed out the code from Northwind and checked each segment against mine -- but it wasn't working at that time for whatever reason.

    It works perfectly now, and you have my gratitude. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  12. #12
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Image Display (WXP Access 2002)

    Chuck
    Glad you sorted it with the help of Hans.
    I couldn't get back to you to continue helping. I had to go home and we had visitors.
    As long as you're now up and running again, glad to have helped, if only a little.

Posting Permissions

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