RE: Show / Hide Fields from a Check Box

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Glad you got it working.
Thanks for letting me know. I was getting cross-eyed trying to figure it out.
--
Dave Hargis, Microsoft Access MVP


"Pattyt" wrote:

I figured it out and I thought I should let you know. I feel so dumb about
this but I must have accidently deleted the control source of my check-box. I
have gone back and added the control source again and it is now working
perfectly.

Thank you very much for your help and I apologize for this.
Take care.

"Klatuu" wrote:

I took this line out, you don't need it:
.OptSigAcq.Enabled = .ChckSelfQa1

Private Sub ChckSelfQa1_AfterUpdate()
With Me
.Label107.Visible = .ChckSelfQa1
.OptSigAcq.Visible = .ChckSelfQa1
End With
End Sub

Now, lets be sure of the naming. OptSigAcq should be the name of the frame
around the options, not the name of one of the options.

I made a minor change here, but I'm not sure it will do any good.

Private Sub Form_Current()
With Me
If .NewRecord Or .ChckSelfQa1 = False Then
.Label107.Visible = False
.OptSigAcq.Visible = False
Else
.Label107.Visible = True
.OptSigAcq.Visible = True

End If
End With
End Sub

Other than the naming, I don't see anything obvious. The way the code reads
is if you check the box the label and and option group are visible and when
you uncheck it, they become invisible,

--
Dave Hargis, Microsoft Access MVP


"Pattyt" wrote:

Hi,
I hope you can figure out what I'm doing wrong.
I have a very similar situation, in my case if the check-box value is true
then I want my option group to show otherwise it shouldn't be visible. I
tried putting code in the afterupdate event of my check-box and on the on
current event of my form but when I for instance check the box on the first
record everything works fine but when I go to the next records the check-box
is checked and the option group shows just like the first record. If I
uncheck the box the option group is not visible on all records.
As a note: my check box is bound to a table but my option group is not.

Here is the code I have:
Private Sub ChckSelfQa1_AfterUpdate()
With Me
.Label107.Visible = .ChckSelfQa1
.OptSigAcq.Visible = .ChckSelfQa1
.OptSigAcq.Enabled = .ChckSelfQa1
End With
End Sub



Private Sub Form_Current()
With Me
If .NewRecord Or .ChckSelfQa1 = False Then
.Label107.Visible = False
.OptSigAcq.Visible = False
Else
.Label107.Visible = .ChckSelfQa1
.OptSigAcq.Visible = .ChckSelfQa1

End If
End With
End Sub

"Klatuu" wrote:

You need code in two places. First, in the form Current event to set the
visibliity for the current record as well as for new records:

With Me
If .NewRecord Or .Grievance_Filed = True Then
.lblGrievanceNbr.Visible = True
.txtGrievanceNbr.Visible = True
Else
.lblGrievanceNbr.Visible = False
.txtGrievanceNbr.Visible = False
End If
End With

And in the After Update event of the check box to change visibility when the
box is checked or unchecked by the user:

With Me
.lblGrievanceNbr.Visible = .Grievance_Filed
.txtGrievanceNbr.Visible = .Grievance_Filed
End With

--
Dave Hargis, Microsoft Access MVP


"scottypws via AccessMonster.com" wrote:

Yes,

It is a "Yes/No" field type in a table. A query pulls in the table fields as
the source to the form.

Scotty

Klatuu wrote:
Is the check box a bound control?
Hello,

[quoted text clipped - 51 lines]

Scotty

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200805/1


.



Relevant Pages