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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Yes/No Button Ticked, Hide Text Boxes

Status
Not open for further replies.

fionama

MIS
Mar 4, 2005
28
IE
Hi, I'm trying to set a tick box on a form so that, if ticked, one text box (SourceOfRequest) will be visible and a number of others invisible, and if not ticked, vice versa.

The code works fine if I'm referring to just one text box (as below) :-

Private Sub StatisticalRequest_AfterUpdate()
If StatisticalRequest = True Then
SourceOfRequest.Visible = True
Else: SourceOfRequest.Visible = False
End If
End Sub

but if I add additional lines such as...


Private Sub StatisticalRequest_AfterUpdate()
If StatisticalRequest = True Then
SourceOfRequest.Visible = True

and MedicalRecordNumber.Visible=False
and Surname.Visible=False...

Else: SourceOfRequest.Visible = False
End If
End Sub

....it's not accepted.
Could you help me with the code please?
Many thanks.
 
just wondering, you haven't left the words 'and' in have you?? this will certainly break it

daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
And what about this ?
Private Sub StatisticalRequest_AfterUpdate()
Me!SourceOfRequest.Visible = Me!StatisticalRequest
Me!MedicalRecordNumber.Visible = Not Me!StatisticalRequest
Me!Surname.Visible = Not Me!StatisticalRequest
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Similiar to PHV's (actually adapted from a suggestion by PHV, long time ago)

Dim blnVisible As Boolean

blnVisible = Me!StatisticalRequest

Me!SourceOfRequest.Visible = blnVisible
Me!MedicalRecordNumber.Visible = Not blnVisible
Me!Surname.Visible = Not blnVisible
 
Had the "and" in the code...stupid me.
Thanks again for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top