Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How To Include ID Pictures In A Report (Access 2.0)

    I work at a high school. Using Access, I need to print a one page report for each student which includes their picture as well as other data. There are over 1800 student pictures (jpeg format) in a directory on our server. Each of these pictures is named with a 4 digit number which is also the student's ID number (for example: 5327.jpg).

    Here are the parameters I am using:

    PicNum table field that contains path and picture name (i.e. S:7716.jpg)

    StudentPhoto image control

    PictureNumber bound text box control (bound to "PicNum" field)


    With the above parameters in mind, I tried this solution using the following lines:

    [PictureNumber] = [PicNum]
    StudentPhoto.Picture = [PictureNumber]

    This results in the error message: "Microsoft can't find the field 'I' referred to in your expression".
    I put this code in the "Open" event in the report form. Is there a "Format" event? If so, I couldn't find it.


    Other solutions I have tried are:

    I set the bound PictureNumber control source to "PicNum" (field in database containing path & picture name).

    With the above parameters in play, I have tried all of the following lines of code (one at a time, of course) and none will work. The error message I get each time is written in caps to the right of code line. If I don't prefix the word "report" to each control, then I get a "Microsoft can't find the field 'I' referred to in your expression".


    Report.StudentPhoto.Picture = Report.[PictureNumber] TYPE MISMATCH
    Report.StudentPhoto.Picture = [Report.PictureNumber] CAN'T FIND "|" FIELD
    Report.StudentPhoto.Picture = Report.PictureNumber TYPE MISMATCH
    Report.StudentPhoto.Picture = [Report].PictureNumber TYPE MISMATCH
    Report.StudentPhoto.Picture = [PictureNumber] TYPE MISMATCH
    [StudentPhoto.Picture] = [PictureNumber] CAN'T FIND "|" FIELD
    StudentPhoto.Picture = [PictureNumber] TYPE MISMATCH


    The "TYPE MISMATCH" has got me stumped. The table field "PicNum" is a text field. If I try the following code, the picture appears in the image control as it should:

    Report.StudentPhoto.Picture = "S:7773.jpg" WORKS

    However, I can't get it to work using any one of the lines of code above.

    Any help would be appreciated. I obviously have the syntax wrong or something.

    Brian

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How To Include ID Pictures In A Report (Access 2.0)

    If your PictureNumber textbox is bound to the PicNum field, you don't need code to set its value. This should work if you put it in the OnFormat event of the Detail section:

    StudentPhoto.Picture = [PictureNumber]
    Charlotte

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How To Include ID Pictures In A Report (Access 2.0)

    Charlotte,

    THANK YOU for your reply. It worked!

    I am confused, however. It works fine in the "Detail" section but when I place the exact same code into the "Report_Open" section I get a "Type Mismatch" error message. Why is that? Since I am trying to learn here, I sure would appreciate a reason why this happens.

    Brian

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How To Include ID Pictures In A Report (Access 2.0)

    There isn't any reason to put it in th Open event. You want it in the report equivalent of the OnCurrent event, which is more or less the detail_format event. I don't know specifically why you're getting a type mismatch, but I suspect that your control may still be Null at that point.
    Charlotte

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How To Include ID Pictures In A Report (Access 2.0)

    Charlotte
    I am trying to do exactly as this poster did i.e. to display a volunteer's photo in a report, but I can't work out what type of control (corresponding to the questioner's "StudentPhoto" image control) to put on the report . The control is to be called VolunteerPic ; I have tried an Image control, Unbound Object Frame control and Bound Object Frame control, but in every case, using the construct VolunteerPic.Picture errors
    Run-Time error 438, Object doesn't support this method or property.
    Clearly I've missed something fundamental.
    What control should I be using/how do I get this working, please? BTW - I am using Access 2003.
    Thanks
    Silverback.
    Silverback

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

    Re: How To Include ID Pictures In A Report (Access 2.0)

    You need to use an Image control, and you must set its Picture property to a text string that contains the path and filename of the image file.

    You'll find a sample database demonstrating how to display images on forms and reports attached to <post#=296,892>post 296,892</post#>.

  7. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How To Include ID Pictures In A Report (Access 2.0)

    Hans
    Thanks for this very useful sample DB. I'm having problems finding time to upgrade my DB - will report back when I've managed this.
    Silverback
    Silverback

  8. #8
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How To Include ID Pictures In A Report (Access 2.0)

    All working fine, now, thank you.
    One thing fooled me for a bit, though. The report has a text box txtCover superimposed over the image control. What is the reason for this?
    The VB code to make the image frame (in)visible seems to work fine without the need to hide it under another control.
    Silverback.
    Silverback

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

    Re: How To Include ID Pictures In A Report (Access 2.0)

    An image control doesn't have a Can Shrink property, a text box does. The text box makes the detail section shrink if there is no picture.

Posting Permissions

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