Open Subform based on required element in master form

D

Don

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
 
M

Marshall Barton

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
. . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top