Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Show images (or not) on an Access 2000 form

    Hi There,

    I have a form that shows 3 images for each record. The images are stored as the full path in the table. example: (f:\images\framed\394888.jpg)

    The images are shown by using the following code: (The same code is in the Form_Current, Form_AfterUpdate, and Form_Load)

    Private Sub Form_AfterUpdate()
    On Error Resume Next
    Me.pPhotoDropShadow.Picture = Me.PhotoDropShadow
    Me.pPhotoFramed.Picture = Me.PhotoFramed
    Me.pPhotoFramedMatted.Picture = Me.PhotoFramedMatted
    Exit Sub

    Question:

    Sometimes the photo doesn't exist. If the photo doesn't exist in the specified folder I would like for an alternative "Noimage.jpg" to be shown instead. Right now if no photo exists it shows me the photo from the last record.

    How can I accomplish this?

    Thanks!

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Is your field where the full path is stored "Null" if there is no image? If so, or if it is an empty text string, you could test for that in the code, and set the path to Noimpage.jpg if the result of the IF statement is true. It appears you would need to check each image path based on the code you are using.
    Wendell

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    371
    Thanked 1,457 Times in 1,326 Posts
    You could try the following which would check for the access value being null as Wendell mentioned and also for the access value having a value but the picture no longer in that location.
    Code:
    Private Sub Form_AfterUpdate()
    On Error Resume Next
    
    if Me.PhotoDropShadow = Null or DIR(Me.PhotoDropShadow) = Null Then
      Me.PhotoDropShadow.Picture = "C:\...\NoImage.jpg"
    '*** Replace ... above with appropriate path info ***
    Else
      Me.pPhotoDropShadow.Picture = Me.PhotoDropShadow
    Endif
    
    '*** Repeat If test logic for each of the following ***
    
    Me.pPhotoFramed.Picture = Me.PhotoFramed
    Me.pPhotoFramedMatted.Picture = Me.PhotoFramedMatted
    
    Exit Sub
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  4. The Following User Says Thank You to RetiredGeek For This Useful Post:

    awckie (2011-06-13)

  5. #4
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WendellB View Post
    Is your field where the full path is stored "Null" if there is no image? If so, or if it is an empty text string, you could test for that in the code, and set the path to Noimpage.jpg if the result of the IF statement is true. It appears you would need to check each image path based on the code you are using.

    No. The full path is in all of the fields whether the picture exists or not.

  6. #5
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by RetiredGeek View Post
    You could try the following which would check for the access value being null as Wendell mentioned and also for the access value having a value but the picture no longer in that location.
    Code:
    Private Sub Form_AfterUpdate()
    On Error Resume Next
    
    if Me.PhotoDropShadow = Null or DIR(Me.PhotoDropShadow) = Null Then
      Me.PhotoDropShadow.Picture = "C:\...\NoImage.jpg"
    '*** Replace ... above with appropriate path info ***
    Else
      Me.pPhotoDropShadow.Picture = Me.PhotoDropShadow
    Endif
    
    '*** Repeat If test logic for each of the following ***
    
    Me.pPhotoFramed.Picture = Me.PhotoFramed
    Me.pPhotoFramedMatted.Picture = Me.PhotoFramedMatted
    
    Exit Sub
    The path will never be null and I don't want to overwrite what is in the field with the "noImage.jpg" path. I just want it to show the "noimage.jpg" or just have it be blank. Is that possible?

  7. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    371
    Thanked 1,457 Times in 1,326 Posts
    If you want to show a picture other than what is stored in the DB then you'll have to place Unbound controls on the form for the pictures and then decide in code what to place there. Of course if you are using this form for update/input purposes you'll also have to write code to take the values in the Unbound controls and update the DB fields where appropriate.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  8. #7
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well that just seems like to much work Thanks for all the help everyone! I appreciate it....

  9. #8
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts
    RetiredGeek,

    I implemented your code and it actually does EXACTLY what I wanted

    Thanks so much!

Posting Permissions

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