I have 10 images on a form only five of which can be selected at any given time. I have five image controls on a report. How can I show the five selected images from my form on the report? Would it be better to have 10 image controls on the report bound to the images and collapse the controls that do not contain data?
Thanks for the reply vbaInet. The images are external to the db. Each selected image path would be stored as a record in a table that is related to my main table. I suppose this would be the correct way.
Not sure yet. Perhaps a checkbox, radio button, or I may border each image with a highlighted rectangle and control their visibility by clicking a transparent command button placed over each image. The later would be my preference but I can get that bit working. I just can't see the forest for the trees and see how I can get the images presented in the image controls of the report.
The simplest control that will display an image is a subform (with an Image control), so you can look into using that. It also allows you to have multiple selections. The other control that will allow you to display images and has a checkbox is a ListView control, but that requires everything to be coded.
You can't control visibility of a control in a Continuous form or a form in Datasheet view using code. But you can mimic it using Conditional Formatting. However, you won't be able to control the Transparency of a control.
On your form:
Name your select box as slctBox0, slctBox1... slctBox9
Create 10 TextBox that hold the name of the picture, and name them txtBox0, txtBox1....
on your report:
Create 5 picture objects and name them PicObj0, PicObj1...
put this code in the Print event of the report section the pictures are on:
Code:
[FONT=Courier New]dim i as integer[/FONT]
[FONT=Courier New]dim p as integer[/FONT]
[FONT=Courier New]dim slctBox as String[/FONT]
[FONT=Courier New]dim txtBox as string[/FONT]
[FONT=Courier New]dim PicObj as string[/FONT]
[FONT=Courier New][/FONT]
[FONT=Courier New]p = 0[/FONT]
[FONT=Courier New][/FONT]
[FONT=Courier New]for i = 0 to 9[/FONT]
[FONT=Courier New] slctBox = slctBox & Cstr(i)[/FONT]
[FONT=Courier New] txtBox = txtBox & Cstr(i)[/FONT]
[FONT=Courier New] if Forms!FormName.Controls(slctBox) = true then[/FONT]
[FONT=Courier New] PicObj = PicObj & Cstr(p)[/FONT]
[FONT=Courier New] me.controls(PicObj).Picture = Forms!FormName.Controls(txtBox)[/FONT]
[FONT=Courier New] p = p + 1[/FONT]
[FONT=Courier New] end if[/FONT]
[FONT=Courier New]next i[/FONT]
On your form:
Name your select box as slctBox0, slctBox1... slctBox9
Create 10 TextBox that hold the name of the picture, and name them txtBox0, txtBox1....
on your report:
Create 5 picture objects and name them PicObj0, PicObj1...
put this code in the Print event of the report section the pictures are on:
Code:
[FONT=Courier New]dim i as integer[/FONT]
[FONT=Courier New]dim p as integer[/FONT]
[FONT=Courier New]dim slctBox as String[/FONT]
[FONT=Courier New]dim txtBox as string[/FONT]
[FONT=Courier New]dim PicObj as string[/FONT]
[FONT=Courier New]p = 0[/FONT]
[FONT=Courier New]for i = 0 to 9[/FONT]
[FONT=Courier New] slctBox = slctBox & Cstr(i)[/FONT]
[FONT=Courier New] txtBox = txtBox & Cstr(i)[/FONT]
[FONT=Courier New] if Forms!FormName.Controls(slctBox) = true then[/FONT]
[FONT=Courier New] PicObj = PicObj & Cstr(p)[/FONT]
[FONT=Courier New] me.controls(PicObj).Picture = Forms!FormName.Controls(txtBox)[/FONT]
[FONT=Courier New] p = p + 1[/FONT]
[FONT=Courier New] end if[/FONT]
[FONT=Courier New]next i[/FONT]