Conditional Pictures in a report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ares6881
    New Member
    • Jul 2007
    • 20

    Conditional Pictures in a report

    Hi, I've run into a snag here and hopefully someone here can help. Basically what I'm trying to do is set it up so the user only needs to place a properly formatted picture in a directory to get it to show up in the report. The problem I'm running into is that each record shows up on two or more pages, when I have my code set to run on current it never runs, so I've tried to run the code on page, the problem is that as soon as I get to the next page, the ProductID shows up as the next record on the list, not the current one. What really makes it confusing is that the rest of the information on the page is still for the correct item. Thanks in advance for any help you can offer.

    Code:
        
    Private Sub Report_page()
        Dim Picture1 As String
        Dim Picture2 As String
        Dim Picture3 As String
        Dim Picture2Genus As String
        Dim Picture3Genus As String
        
        Picture1 = "P:\Lab Pictures\" & ProductID & "Stock.jpg"
        Picture2 = "P:\Lab Pictures\" & ProductID & "St2.jpg"
        Picture3 = "P:\Lab Pictures\" & ProductID & "St3.jpg"
        Picture2Genus = "P:\Lab Pictures\" & Left(ProductID, 3) & "St2.jpg"
        Picture3Genus = "P:\Lab Pictures\" & Left(ProductID, 3) & "St3.jpg"
        
        If Dir(Picture1) = "" Then 'Checks for Stock Picture
            Me!Image1.Picture = "P:\AccessPics\nopic.bmp"
        Else
            Me!Image1.Picture = Picture1
        End If
        
        If Dir(Picture2) = "" Then 'Checks for Stage 2 Picture
            If Dir(Picture2Genus) = "" Then 'Checks for Genus Stage 2Picture
                Me!Image2.Picture = "P:\AccessPics\nopic.bmp"
            Else
                Me!Image2.Picture = Picture2Genus
            End If
        Else
            Me!Image2.Picture = Picture2
        End If
            
        If Dir(Picture3) = "" Then 'Checks for Stage 3 Picture
            If Dir(Picture3Genus) = "" Then 'Checks for Genus Stage 3 Picture
                Me!Image3.Picture = "P:\AccessPics\nopic.bmp"
            Else
                Me!Image3.Picture = Picture3Genus
            End If
        Else
            Me!Image3.Picture = Picture3
        End If
    End Sub
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    I'm trying to do is set it up so the user only needs to place a properly formatted picture in a directory to get it to show up in the report. The problem I'm running into is that each record shows up on two or more pages, when I have my code set to run 'on current' it never runs
    Ares6881, I'm a little confused since Reports do not have a Current() Event.

    Comment

    • Ares6881
      New Member
      • Jul 2007
      • 20

      #3
      I'm running Access 2007, it's showing up as an option for some reason, I can post a screen shot, but right now I'm using the on Page event anyway.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by Ares6881
        I'm running Access 2007, it's showing up as an option for some reason, I can post a screen shot, but right now I'm using the on Page event anyway.
        This is very difficult to envision what is going on without the actual DB. If I sent you my E-Mail Address in a Private Message, would you be able to send me the Database, or a subset of it, along with some sample graphics?

        Comment

        • Ares6881
          New Member
          • Jul 2007
          • 20

          #5
          Unfortunately, the database itself contains proprietary information, and with all the links to other tables, etc.. It would likely take quite a bit to break it out. Essentially what's going on is when the on page event runs the information is from the next page instead of the page that I'm on, and since it's in two pages the first page has the correct information, while the second one has the information for the next item on the list (in the VBA code only). As a stop gap I've moved all the photos to the first page so they are showing correctly now.

          Here's an example of how things are showing up:

          Page.......---1 2 3 4 5 6

          ProductID---A A B B C C

          ProductID---A B B C C D
          showing up
          in VB Code

          Comment

          Working...