Show / Hide Form depending on data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OzNet
    New Member
    • Aug 2007
    • 31

    #1

    Show / Hide Form depending on data

    Hi

    I have a main form and want to put two subforms on a tabbed control (on the same tab)

    Subform 1 will display data if it corresponds with the data on the main form. When this is true, subform 2 will be blank

    Likewise, subform 2 will display data if it corresponds with the data on the main form and when this is true, subform1 will be blank.

    How can I make the subforms visible only when there is data present?

    I have only worked with one subform at this stage and this is what I have tried:

    Code:
    Private Sub Form_Open(Cancel As Integer)
        If (IsNull(txtLumpSumTot)) Then
        Forms!afrmProjectReview!subfrmPJLSEstimate.Form.Visible = True
        Else
        Forms!afrmProjectReview!subfrmPJLSEstimate.Form.Visible = False
        End If
    End Sub
    This code is attached to one of the subforms on the tabbed control.
    txtLumpSumTot is a calculated textfield on the subform but I have tried other fields. I also tried the same code on the OnDirty property.

    The subform either is hidden or visible depending if I swap the true and false status around.
  • RuralGuy
    Recognized Expert Contributor
    • Oct 2006
    • 375

    #2
    The RecordSet.Recor dCount will be 0 if there are no records.
    From the MainForm the syntax is:
    Me.subfrmPJLSEs timate.Form.Rec ordSet.RecordCo unt

    Comment

    • OzNet
      New Member
      • Aug 2007
      • 31

      #3
      Thanks RuralGuy

      That did the trick!

      Comment

      • RuralGuy
        Recognized Expert Contributor
        • Oct 2006
        • 375

        #4
        That's great! Glad I could help.

        Comment

        Working...