By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Conditional Pictures in a report

P: 20
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Report_page()
  3.     Dim Picture1 As String
  4.     Dim Picture2 As String
  5.     Dim Picture3 As String
  6.     Dim Picture2Genus As String
  7.     Dim Picture3Genus As String
  8.  
  9.     Picture1 = "P:\Lab Pictures\" & ProductID & "Stock.jpg"
  10.     Picture2 = "P:\Lab Pictures\" & ProductID & "St2.jpg"
  11.     Picture3 = "P:\Lab Pictures\" & ProductID & "St3.jpg"
  12.     Picture2Genus = "P:\Lab Pictures\" & Left(ProductID, 3) & "St2.jpg"
  13.     Picture3Genus = "P:\Lab Pictures\" & Left(ProductID, 3) & "St3.jpg"
  14.  
  15.     If Dir(Picture1) = "" Then 'Checks for Stock Picture
  16.         Me!Image1.Picture = "P:\AccessPics\nopic.bmp"
  17.     Else
  18.         Me!Image1.Picture = Picture1
  19.     End If
  20.  
  21.     If Dir(Picture2) = "" Then 'Checks for Stage 2 Picture
  22.         If Dir(Picture2Genus) = "" Then 'Checks for Genus Stage 2Picture
  23.             Me!Image2.Picture = "P:\AccessPics\nopic.bmp"
  24.         Else
  25.             Me!Image2.Picture = Picture2Genus
  26.         End If
  27.     Else
  28.         Me!Image2.Picture = Picture2
  29.     End If
  30.  
  31.     If Dir(Picture3) = "" Then 'Checks for Stage 3 Picture
  32.         If Dir(Picture3Genus) = "" Then 'Checks for Genus Stage 3 Picture
  33.             Me!Image3.Picture = "P:\AccessPics\nopic.bmp"
  34.         Else
  35.             Me!Image3.Picture = Picture3Genus
  36.         End If
  37.     Else
  38.         Me!Image3.Picture = Picture3
  39.     End If
  40. End Sub
  41.  
Nov 19 '08 #1
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,597
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.
Nov 20 '08 #2

P: 20
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.
Nov 20 '08 #3

ADezii
Expert 5K+
P: 8,597
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?
Nov 21 '08 #4

P: 20
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
Nov 21 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.