set field to visible or invisible

sock

New member
Local time
Today, 07:02
Joined
Aug 17, 2009
Messages
4
Hi, I have a little problem. I would like one field called Risk_Assessment to be set to visible if Age is under 19 and set to invisible if over 19. Please can you help with the code and explain where I should put it. This is what I have done and it does not work:

Private Sub Risk_Assessment_BeforeUpdate(Cancel As Integer)
If Me.Age <= 19 Then
Me.Risk_Assessment.Visible = True
Else
Me.Risk_Assessment.Visible = False
End If
End Sub
 
Assuming that age and Risk_Assessment are names of controls on the same form, I think that the code should be in the on current event of the form since you would want this code to trigger for each record of the form's recordset.
 
You could also use Conditional Formatting (you can't set visibility itself, but you can make the font the same color as the background to achieve the same effect). This would probably be a better option on a continuous form.
 
Interesting Solution pBaldy. I never thouht of that and it is probably better because every Record will be formatted not just the current record on a continous form.

I heard that they are making Atlas Shrugged into a movie.
 
Thanks ions. I've heard that too, though it's been rumored for years. Hopefully they'll finally get it going.
 

Users who are viewing this thread

Back
Top Bottom