Show label only if fields in subform are not null

  • Thread starter nerb61 via AccessMonster.com
  • Start date
N

nerb61 via AccessMonster.com

I want to display a label on my main form only when certain fields on my
subform are not null. I know my code is incorrect, but I need help making it
right. Thanks in advance.

Sub ShowIssueComplete()

If Me.frmQuestions.Response1.IsNull = True
Me.frmQuestions.Response2.IsNull = True
Me.frmQuestions.Response3.IsNull = True
Me.frmQuestions.Response4.IsNull = True
Me.frmQuestions.Response5.IsNull = True
Me.frmQuestions.Response6.IsNull = True

Then
Me.lbDecisionComplete.Visible = True

Else
Me.lbDecisionComplete.Visible = False

End If

End Sub
 
B

Barry Gilbert

Try this:
Sub ShowIssueComplete()

If IsNull(Me.frmQuestions.Form.Response1) And _
IsNull(Me.frmQuestions.Form.Response2) And _
IsNull(Me.frmQuestions.Form.Response3) And _
IsNull(Me.frmQuestions.Form.Response4)l And _
IsNull(Me.frmQuestions.Form.Response5) And _
IsNull(Me.frmQuestions.Form.Response6) Then

Me.lbDecisionComplete.Visible = True

Else
Me.lbDecisionComplete.Visible = False

End If

End Sub

It assumes you want the Visibility based on all fields being null. If
not, replace the ANDs with ORs.

Barry
 
K

Klatuu

Here is a little technique that will minimize the amount of coding you will
need.

Dim intCtr As Integer
Dim blnMakeVisible as Boolean

blnMakeVisible = True
With Me.frmQuestions
For intCtr = 1 to 6
If Not IsNull(.Controls("Response" & Cstr(intCtr))) Then
blnMakeVisible = False
Exit For
End If
End With
Me.lbDecisionComplete.Visible = blnMakeVisible
 
Top