Results 1 to 8 of 8
  1. #1
    V-Clan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2015
    Posts
    4

    Need Help wtih Images on Forms


    Hello -

    I'm working on a database for my comics and learning as I go. For each record on my form "Comic Entry" I have an image of the Cover of the comic showing on the form record. This image changes with each record. However, there are some records that I do not have an image for, yet the the record still populates with an image (the last recorded filepath in the table 'Comic info'). I would like there to be no image if I do not have one loaded for a particular record.

    All stored data is in one table to include fields: FilePath and FileName. Below is the code I've used (found on another site) in order to have my images populate for each record;
    Code:
    Option Compare Database
    Option Explicit
    Private Sub On_Load()
             If Me.FilePath > 0 Then
             Me.ImageFrame.Visible = True
             Else
             Me.ImageFrame.Visible = False
             End If
    End Sub
    
    Private Sub Form_AfterUpdate()
             Me.bywho.Visible = Me.Signed
             On Error Resume Next
             Me![ImageFrame].Picture = Me![FilePath] & Me![FileName]
             Me![txtPath] = Me![FilePath] & Me![FileName]
             
    End Sub
    
    Private Sub Form_Current()
             Me.bywho.Visible = Me.Signed
             On Error Resume Next
             Me![ImageFrame].Picture = Me![FilePath] & Me![FileName]
             Me![txtPath] = Me![FilePath] & Me![FileName]
    
    End Sub
    
    Private Sub ImageFrame_Click()
    
    End Sub
    The If statement is something I started messing around with tonight to see if I could have the ImageForm not visible if the corresponding record's FilePath field was blank. I'm not having any luck there yet. I'm not receiving any errors on it but it's not recognizing what I'm trying to have it do.

    I'm using Access 2003 on Windows 7 64-bit.

    Thanks in advance for any help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I would check for an empty string instead of checking for a numeric value. And I would not use the OnLoad, except maybe to set the Image Frame to ... Me![ImageFrame].Picture = ""

    I would use the On Current to check for the Value of the Path and FileName. So maybe something like...

    Code:
    If Me.FilePath > "" AND   Me![FileName] > "" Then
             Me![ImageFrame].Picture = Me![FilePath] & Me![FileName]
             Me.ImageFrame.Visible = True
             Else
             Me![ImageFrame].Picture = ""
             Me.ImageFrame.Visible = False
             End If

  3. #3
    V-Clan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2015
    Posts
    4
    Thank you very much ItsMe for your suggestions/tips and code for my image challenge. Things are working great as a result!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If you upgrade Access, dynamic display of images can be done without any VBA code. Image control now has a ControlSource property.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You are welcome.

  6. #6
    V-Clan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2015
    Posts
    4
    Quote Originally Posted by June7 View Post
    If you upgrade Access, dynamic display of images can be done without any VBA code. Image control now has a ControlSource property.
    June, that is awesome to know. What's the earliest version of Access that has this?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Access 2007. Probably hard to find.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    V-Clan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2015
    Posts
    4
    Great, thank you!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 04-15-2015, 11:22 AM
  2. Images disappearing from forms
    By jopi in forum Forms
    Replies: 1
    Last Post: 09-22-2014, 09:30 AM
  3. Inserting printable images in forms
    By Sash in forum Forms
    Replies: 1
    Last Post: 03-17-2014, 11:05 AM
  4. Replies: 1
    Last Post: 10-05-2012, 08:28 PM
  5. Access 2010 - Images on Forms
    By dluhop in forum Forms
    Replies: 23
    Last Post: 10-05-2011, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums