Discussion Locked

Access Check Box Visibility

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a table, which contains a combo box called 'Complaint Type' that allows the user to select 'Claims Issues' or 'Contract Issues'. This table also contains yes/no fields that relate to the complaint type chosen. A few are CL-Claim Denied, CL-Claim Paid, CT-Contract Terminated, and CT-New Contract. I built a form, and I am trying to write code that will only display the yes/no check boxes that are associated with the complaint type chosen. For example, if the user selects the complaint type 'Claims Issues', I want only the yes/no check boxes CL-Claim Denied, and CL-Claim Paid to appear on the form. If the user selects 'Contract Issues', I only want to see 'CT-Contract Terminated' and 'CT-New Contract' on the form.

I know my sorry attempt at writing the code is missing quite a bit?.can anyone pleeeease help me with this? Thanks!!!

Private Sub Complaint_Type_Category_Codes_Click()
If Me.Complaint_Type_Category_Codes = "Claims Issues" Then
CL-Claim Denied.Visible = True
CL-Claim Paid.Visible = True
If Me.Complaint_Type_Category_Codes = "Contract Issues" Then
CT-Contract Terminated.Visible = True
CT-New Contract.Visible = True
Else
CL-Claim Denied.Visible = False
CL-Claim Paid.Visible = False
CT-Contract Terminated.Visible = False
CT-New Contract.Visible = False
End If
End If
End Sub

6 replies

by don christner

You have your IF statements nested wrong. The way it is written, it can not get to the second IF statement, nor the ELSE statement. I think it would be easier for you to use SELECT CASE. Make a CASE statement for "claims issues" and "contract issues" and within each CASE, show or hide the choices you want.

Don

by chainsawz

You guys are awesome! I increased the points on this since both the methods worked for me. Utimately, I used the SELECT CASE due to the number of cases I actually had. Thanks for saving me!!

by glen_mcleod

Here's your code cleaned up a bit:

If Me.Complaint_Type_Category_Codes = "Claims Issues" Then

CL-Claim Denied.Visible = True
CL-Claim Paid.Visible = True

ElseIf Me.Complaint_Type_Category_Codes = "Contract Issues" Then

CT-Contract Terminated.Visible = True
CT-New Contract.Visible = True

Else

CL-Claim Denied.Visible = False
CL-Claim Paid.Visible = False
CT-Contract Terminated.Visible = False
CT-New Contract.Visible = False

End If

I really try to stay awayfrom lots of 'ElseIf' clauses, but with only 3 cases here, it's not too bad. The above answer using 'Select Case' will work too, but here's the code for you to copy and paste.

Glen

by chainsawz

You guys are awesome! I increased the points on this since both the methods worked for me. Utimately, I used the SELECT CASE due to the number of cases I actually had. Thanks for saving me!!

This discussion is closed to new replies.