Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selective Displaying of Images

Status
Not open for further replies.

stgill

Instructor
Aug 6, 2003
11
AU
I have a text box that will contain a value from 1 to 4. Beside this I will have a series of images in columns. Initially, all images will be invisible. I would like to be able to display a particular image depending on what the value in the text box is eg: if the value is 1, then the first image is seen. Any ideas appreciated.
 
In the relevant sections' OnFormat event, you need code something like:
Code:
Select Case nameOfYourTextBoxHere.Value
Case 1
    nameOfFirstPictureControlHere.Visible = True
    nameOfSecondPictureControlHere.Visible = False
    nameOfThirdPictureControlHere.Visible = False
    nameOfFourthPictureControlHere.Visible = False
Case 2
    nameOfFirstPictureControlHere.Visible = False
    nameOfSecondPictureControlHere.Visible = True
    nameOfThirdPictureControlHere.Visible = False
    nameOfFourthPictureControlHere.Visible = False
Case 3
    nameOfFirstPictureControlHere.Visible = False
    nameOfSecondPictureControlHere.Visible = False
    nameOfThirdPictureControlHere.Visible = True
    nameOfFourthPictureControlHere.Visible = False
Case 4
    nameOfFirstPictureControlHere.Visible = False
    nameOfSecondPictureControlHere.Visible = False
    nameOfThirdPictureControlHere.Visible = False
    nameOfFourthPictureControlHere.Visible = True
End Select
Hope this is clear enough - obviously you'll need to change all field names as required.

Hope this helps.
 
Thanks - this works on the form. However, I can't get to selectively display the images on the report. Any more ideas would be appreciated.
 
Hey,

Im guessing that you want the report to be displayed depending on how th form is laid out?

If so declare a Global in a module

Global IntVisbleImage as Integer

Then in your form select case do exactly as mp9 has done but with the variable put this...

Select Case nameOfYourTextBoxHere.Value
Case 1
nameOfFirstPictureControlHere.Visible = True
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = False
IntVisbleImage = 1
Case 2
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = True
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = False
IntVisbleImage = 2
Case 3
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = True
nameOfFourthPictureControlHere.Visible = False
IntVisbleImage = 3
Case 4
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = True
IntVisbleImage = 4
End Select

Now in the form activate of your report put this....

Select Case IntVisbleImage
Case 1
nameOfFirstPictureControlHere.Visible = True
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = False
Case 2
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = True
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = False
Case 3
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = True
nameOfFourthPictureControlHere.Visible = False
Case 4
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = True
End Select

This will now mimic your form.

If this isn't what you want to do then message back n i'll see what I can do

hope this helps

Sam
 
Still can't get it to work.

The images are not needed on the form. When using the form, the user selects one of four options held in a frame - each option is assigned a value from 1 to 4.

When the user then views the report, one of 4 images is to appear depending on which option was selected on the form. At the moment, the images are not stored in a table. I was hoping to place them on the report, set the visible property to false, then show one depending on the option selected.

Thanks for efforts so far.
 
Sorry just read my last post n realised i screwed up a little, If ya tell me the following I should be able to post the correct code...

Do you have an 'OK' button? or as soon as you click the correct option button do you want to go to the report?

Cheers

Sam
 
There will be a command button that opens the report.

Peter
 
Hey,

Ok this is the same layout (virtually) that I use.


This goes into your command button.


Select Case nameOfYourTextBoxHere
Case 1
IntVisbleImage = 1
Case 2
IntVisbleImage = 2
Case 3
IntVisbleImage = 3
Case 4
IntVisbleImage = 4
End Select


This can go into the Report CURRENT ("Private Sub Report_Current").

The code is as follows...

Select Case IntVisbleImage
Case 1
nameOfFirstPictureControlHere.Visible = True
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = False
Case 2
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = True
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = False
Case 3
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = True
nameOfFourthPictureControlHere.Visible = False
Case 4
nameOfFirstPictureControlHere.Visible = False
nameOfSecondPictureControlHere.Visible = False
nameOfThirdPictureControlHere.Visible = False
nameOfFourthPictureControlHere.Visible = True
End Select


This should work as long as you have declared your variable in a module.

Good Luck

Sam
 
Finally got it working - thanks.

Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top