CheckBox.check = show picture

voidcranium

Registered Something.
Local time
Today, 15:41
Joined
Oct 29, 2006
Messages
175
Hello I'm at a loss on how to get this to work.

I have a check box and I want it to show a picture if it is checked and hide the
picture if it not checked.
I dont know where to put it either, do I put it in the form load procedure or in
the checkbox procedure?
Basically I want the user to check the box if it is needed and when they open
it later they will see the checked box and the picture.

Here is what I am messing with.

If checkBox.?????? = ? Then
imgPicture.visible = True
Else
imgPicture = False
End if

I cant figure out how to do this.

I'm using Access 2002

Thanks for the help.
 
Last edited:
just if checkbox

implied test is "if checkbox= true"

probably the best place to put this is in the on current event
 
Spot-on, Gemma.
 
gemma-the-husky said:
just if checkbox

implied test is "if checkbox= true"

probably the best place to put this is in the on current event

Where is that current event?
 
It is one of the Form's events. To get there, open your form in design view, click on the drop down that lists all objects on the form, including the form itself (it's the drop down on the toolbar and is on the far left hand side - at least the default location is there) and then select FORM from it. Open the properties window by either clicking the toolbar icon of a hand pointing to a form, or select VIEW / PROPERTIES from the menu.

Click on the EVENTS tab in the properties and it should be there in the list of different events like Click, DblClick, Current, etc.
 
Sorry guys but I can seem to get any of these suggestions to work.
I even created a new form, checkbox and image put that code in and
NOTHING happens.

Got any other ideas?

I didn't think this would be that hard.

Thanks
 
To recap, in the forms current event, and then in the checkbox after update event put

If mycheckBoxname Then
imgPicture.visible = True
Else
imgPicture = False
End if

you could even just put
imgpicture.visible = mycheckboxname

imgpicture should be the name of the control on your form
mycheckboxname is the name of the checkbox on your form
 
gemma-the-husky said:
To recap, in the forms current event, and then in the checkbox after update event put

If mycheckBoxname Then
imgPicture.visible = True
Else
imgPicture = False
End if

you could even just put
imgpicture.visible = mycheckboxname

imgpicture should be the name of the control on your form
mycheckboxname is the name of the checkbox on your form

Thank You so much. :)

I got it to work, I did not realize I had to put the code in 2 different spots.

Here is the final code I used:
Code:
Private Sub Form_Current()
If Me.checkBoxStar_List Then
Me.imgStar.Visible = True
Else
Me.imgStar.Visible = False
End If
End Sub

Private Sub checkBoxStar_List_AfterUpdate()
If Me.checkBoxStar_List Then
Me.imgStar.Visible = True
Else
Me.imgStar.Visible = False
End If
End Sub

Now on to my other problem. :)

Thanks again.
 
yes, the current event deals with it when each item first appears. the after update event deals with the change. To avoid flickering, it might be better to set the initial property of the image to not visible. Otherwise when the form opens it mayl briefly start visible, and then go invisible, depending on the first test.
 
I know this is a VERY old post but I recently picked up a project where I require this same idea. Except, I'd like to perform multiple of the same event on the same form. Basically, I want my page to recognize multiple check boxes to reveal different images that show which groups are and aren't involved with a project. When I add the second Form_Current() event I receive the error

"the expression on current you entered as the event property setting produced the following error: Ambiguous name detected: Form_Current."

Can someone please help define how I can create this effect multiple times? I will be using it roughly 10 times in the same form with 10 different check boxes and 10 different images.

Thank you,
Resident
 

Users who are viewing this thread

Back
Top Bottom