Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Locate Image (2003)

    I've looked through the posts concerning images, but can't seem to find what I require. I wnat a user to type their name on a form, but when a report is run, a relevant picture appears. All pictures are stored in one folder, and are bmp.

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

    Re: Locate Image (2003)

    Place an Image control on the report. Access will prompt you to specify an image file - choose any, it doesn't matter (but don't cancel the dialog, for then the Image control will disappear).
    Next. clear the Picture property of the Image control. Confirm that you want to clear the image.

    Put code in the On Open event of the report to load the appropriate image into the control. For example:

    Private Sub Report_Open(Cancel As Integer)
    ' Avoid errors if the file is missing
    On Error Resume Next
    Me.imgPicture.Picture = "C:Images" & Forms!frmSomething!txtName & ".bmp"
    End Sub

    imgPicture is the name of the image control.
    frmSomething is the name of the form.
    txtName is the name of the text box in which the user types his/her name.
    The code assumes that for a user named Rob, there is a file named Rob.bmp in the folder C:Images, i.e. C:ImagesRob.bmp.
    You must of course change the names of the controls, form and of the folder.

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locate Image (2003)

    Typed in the code as you suggested, but no image appears. I've put the code as
    Me.Image2.Picture ="C:bmp" & Forms!Form1!Eng_Clerk_Sign &".bmp"

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

    Re: Locate Image (2003)

    Is the Form1 form open and the Eng_Clerk_Sign text box filled in when the report is opened? And does Eng_Clerk_Sign contain the name of an existing file (minus the extension)?

  5. #5
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locate Image (2003)

    The form is closed, but the field is filled in on the form, with the name of the image without the extention. Does the Eng_Clerk_Sign have to be present on the report?

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

    Re: Locate Image (2003)

    If Form1 is closed, you cannot refer to Forms!Form1!...
    So keep the form open, or store the value in a global variable or in a table, and refer to that.

  7. #7
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locate Image (2003)

    I've got this code on the form

    Option Compare Database

    Public Signature As String

    Private Sub Form_Close()
    'Avoid Errors if the file is missing
    On Error Resume Next
    Signature = "C:bmp" & Forms!Form1!ENG_CLERK_SIGN & ".bmp"

    End Sub

    and this code on the report

    Private Sub Report_Open(Cancel As Integer)
    'Avoid errors if file is missing
    On Error Resume Next
    Me.Image2.Picture = Signature
    End Sub

    but get errors. I'm not sure if I've done this correctly

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

    Re: Locate Image (2003)

    Put the declaration

    Public Signature As String

    in a general module (the kind you create by selecting Insert | Module) instead of in the form module.

  9. #9
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locate Image (2003)

    The image is being found now. The problem is that, although there are different names on the form, the same signature appears on the report.

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

    Re: Locate Image (2003)

    Do you mean that you want a different signature for each record?

  11. #11
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locate Image (2003)

    Yes, that's right. I've probably gone the totally wrong way about this haven't I

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

    Re: Locate Image (2003)

    You can't use a global variable and the Report_Open event for what you want. The filenames of the pictures should be stored in the table; you can then use the Detail_Format event to set the picture for each record. The database attached to <post#=296892>post 296892</post#> demonstrates how to do this in a form and in a report.

  13. #13
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locate Image (2003)

    It's not as simple as in the demo. My report runs from a query, so there's nothing to attach the table with the image locations to.

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

    Re: Locate Image (2003)

    How can we determine which picture belongs to which record?

  15. #15
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locate Image (2003)

    All the images are persons names, and they type this name into different controls on the form eg, Engineer, Production Manager. All these controls are linked to a log No.

Page 1 of 3 123 LastLast

Posting Permissions

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