set visibility of a sub form depending on the checkbox value of the main form

saleemMSMS

Registered User.
Local time
Tomorrow, 00:15
Joined
Aug 12, 2009
Messages
92
hi ..
my main form has a check box named additional details (the main form is student form btw)
the main form has basic details of a student. if the check box named require additional details is clicked, the sub form is visible and the user will have the ability to enter data.
but when the check box is not checked (the default option), the sub form is hidden.

this main form and the sub form has 2 different tables. in the main table, there is a column to store a yes/no value which is being captured by the "require additional details" column.
now, what i want is say u enter a record and it gets saved in the sub form as well. what i want is, whenever we navigate through the form's data, i need the sub form to be visible for students with additional details; and hide for students who don't have additional details

i tried the following code in the on current and check box clicked events of the main form but didnt get an answer...
please help
thanx.
Code:
If Me.Check10.Value = -1 Then 'Checked returns as -1 or "True"
   Me!StudentSub.Form.Visible = False
Else
  Me!StudentSub.Form.Visible = True
End If
 
You need to set the Visible property of the subformcontrol rather than the subform object it contains.
I think you also have the logic backwards from your description.

You can also simplify the code to a single line.

Me!subformcontrolname.Visible = Me!Check10
 

Users who are viewing this thread

Back
Top Bottom