1

I have a report for printing labels on a grid of let's say 3 by 6 on A4 paper. These are peel-off labels, which can be printed either full sheet or just 1, depending on needs.

The report's record source is a query, which contains always 18 records (to cover a 3x6 grid), and 3 columns: [ID] (1-18), [LabelText], and [Path]. Out of these 18 records sometimes all 18 LabelText and Path are populated, but sometimes only the first few (and the rest is empty "" ), but also it could be that say first 4 are empty, then 6 have data and the rest 8 are empty. ID is always populated with numbers 1 to 18. This is done so that labels on A4 are not wasted.

Each printed label should contain a different image based on the file path given in column [Path]. This is achieved with the Detail On Format event

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
   Me.Image0.Picture = Me.path
End Sub

All works with a problem.

  1. If all 18 labels are filled, all is correct
  2. If say first 3 records are filled, then the first 3 labels get the correct Image, but all the rest of the 15 labels also get the last image (from label 3)
  3. If say first 3 records are empty and the next 3 records have data and the rest is empty, then the first 3 labels have no image (as it should be) labels 4-6 have a correct image and the rest again get the last image (from label 6)

I tried many different "If/Else" options in the On Format event, but always get the same result. There must a simple solution, but I am not seeing it.

Monardo
  • 23
  • 4

1 Answers1

1

As you have the path (even empty), you could use a bound image control.

Simply set its ControlSource to: Path

For an example, see the demo at my project VBA.PictureUrl.

Gustav
  • 53,498
  • 7
  • 29
  • 55