Originally Posted by
KNap
If two field names on the same form say "yes"
Just so you understand the terms, Tables have FIELDS, Forms have CONTROLS.
Originally Posted by
KNap
([FRM - Housing History]![Is Client a Care Leaver?]="Yes" And [FRM - Housing History]![If 'Yes' Is Client under 21 yrs of Age?]="yes") then
You should Google "Naming Conventions".
Object names should only be letters, numbers or the underscore.
NO spaces, punctuation or special characters.
Object names should be short but descriptive.
These are poor form names:
"FRM - Housing History".
"POP UP Social Services Duty of Care".
Better form names would be:
"frmHousingHistory" or "frmHousing_History"
"POPUP_SocialServicesDuty_of_Care" or "POPUP_SocialServicesDutyOfCare"
These are poor field names:
[Is Client a Care Leaver?]
[If 'Yes' Is Client under 21 yrs of Age?]
They have spaces, single quotes and the question mark.
Better names would be:
[ClientIsCareLeaver] or [Client_Is_Care_Leaver]
[ClientIsUnder21] or [Client_Is_Under_21]
This is NOT a macro. This is code....
Code:
Private Sub If__Yes__Is_Client_under_21_yrs_of_Age__Click() '<< Can't have nested Subs
Sub cmoBox1_afterupdate()
CheckYes
End Sub
Sub cmoBox2_afterupdate()
CheckYes
End Sub
Sub CheckYes()
If cboBox1 = "Yes" And cboBox2 = "Yes" Then DoCmd.OpenForm "POP UP Social Services Duty of Care"
End Sub
End Sub '<<< too many "End Sub"s
Private Sub Is_Client_a_Care_Leaver__AfterUpdate() '<< Can't have nested Subs
Sub cmoBox1_afterupdate()
CheckYes
End Sub
Sub cmoBox2_afterupdate()
CheckYes
End Sub
Sub CheckYes()
If cboBox1 = "Yes" And cboBox2 = "Yes" Then DoCmd.OpenForm "POP UP Social Services Duty of Care"
End Sub
End Sub '<<< too many "End Sub"s
It sounds like you have two text boxes on the form, so the code might look like:
Code:
Private Sub If__Yes__Is_Client_under_21_yrs_of_Age__AfterUpdate() '<< Can't have nested Subs
CheckYes
End Sub
Private Sub Is_Client_a_Care_Leaver__AfterUpdate() '<< Can't have nested Subs
CheckYes
End Sub
Sub CheckYes()
If If__Yes__Is_Client_under_21_yrs_of_Age = "Yes" And Is_Client_a_Care_Leaver = "Yes" Then
DoCmd.OpenForm "POP UP Social Services Duty of Care"
End IF
End Sub
If the two controls are check boxes, try:
Code:
Private Sub If__Yes__Is_Client_under_21_yrs_of_Age__Click() '<< Can't have nested Subs
CheckYes
End Sub
Private Sub Is_Client_a_Care_Leaver__Click() '<< Can't have nested Subs
CheckYes
End Sub
Sub CheckYes()
If If__Yes__Is_Client_under_21_yrs_of_Age = TRUE And Is_Client_a_Care_Leaver = TRUE Then
DoCmd.OpenForm "POP UP Social Services Duty of Care"
End IF
End Sub
"Yes" is a text string. True is a Boolean value. Depending on the field type the control is bound to determines what you compare the control value to.
If the control value is a Boolean, use TRUE. If the control value is a Text String, use "Yes".