That won't address the "not required" aspect, right?. This isn't a job for IIF - it's a job for IF.
You'll need to use the combo's AfterUpdate event as noted. You'll also need a way to single out the controls involved. For this, I'd enter Reqd (no quotes) in the Tag property for each control involved. I think you can do this in a batch (select all of them then make the Tag entry on the property sheet).
Are you sure you want to hide the controls rather than disable them?
You put this into a standard module so that it can be called from many places in your db:
Code:
Function HasNoData(vCheckVal As Variant) As Boolean
HasNoData = False
If IsNull(vCheckVal) Or vCheckVal = "" Then HasNoData = True
End Function
This goes in your combo AfterUpdate event code:
Code:
Dim ctl As Control
Dim svList As String, svList2 As String
svList = "Please enter a value for: " & vbCrLf
svList2 = ""
If Me.NameOfYourCombo = "Yes" Then
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox 'ADD OTHER TYPES AS REQUIRED
If ctl.Tag = "Reqd" Then
If HasNoData(ctl) Then svList2 = svList2 & ctl.Controls.Item(0).Caption & vbCrLf
End If
End Select
ctl.Visible = True
Next
If svList2 <> "" Then
MsgBox svList & svList2, vbOKOnly, "Missing Information"
Exit Sub 'comment out or remove this line if you don't want to stop the code when there's missing required info
Else 'if combo can have other values than Yes or No, then another If is needed. The assumption here is that it's one or the other.
ctl.Visible = False
'there's no point in worrying about a control not being required if you can't even see it.
End If
The label has to be attached/associate with a control otherwise .Item(0).Caption will generate an error. You could use the control name if it's not confusing to the user. Alternatively, you can color its background or do something else to indicate required.
NOTE - this version of otherwise working code is untested.