Open Subform based on required element in master form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a master form which is named "frmInvICN". On that form I have controls
[strICN], [strPIN], and [strHICN] which are all set to require data. If any
of these controls are left null, then I do not want my subform named
"fsubInvDetail" to be visible. I have tried the followng command (from
another similar posting) on the current event but the subform is showing
regardless of whether or not the contol values are null or not. Can you look
at my code and tell me where I have gone wrong?

Private Sub Form_Current()
If Me![strICN] = Null OR Me![strPIN] = Null OR Me![strHICN] = Null Then
Me!fsubInvDetail.Visible = False
Else
Me!fsubInvDetail.Visible = True
End If
End Sub
 
Don said:
I have a master form which is named "frmInvICN". On that form I have controls
[strICN], [strPIN], and [strHICN] which are all set to require data. If any
of these controls are left null, then I do not want my subform named
"fsubInvDetail" to be visible. I have tried the followng command (from
another similar posting) on the current event but the subform is showing
regardless of whether or not the contol values are null or not. Can you look
at my code and tell me where I have gone wrong?

Private Sub Form_Current()
If Me![strICN] = Null OR Me![strPIN] = Null OR Me![strHICN] = Null Then
Me!fsubInvDetail.Visible = False
Else
Me!fsubInvDetail.Visible = True
End If
End Sub


You can not compare Null to anything, not even itself. Use
this instead:

If IsNull(Me!strICN] OR IsNull(Me!strPIN) _
OR IsNull(Me!strHICN) Then
. . .
 
Back
Top