By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,863 Members | 853 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,863 IT Pros & Developers. It's quick & easy.

Show / Hide Form depending on data

P: 31

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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     If (IsNull(txtLumpSumTot)) Then
  3.     Forms!afrmProjectReview!subfrmPJLSEstimate.Form.Visible = True
  4.     Else
  5.     Forms!afrmProjectReview!subfrmPJLSEstimate.Form.Visible = False
  6.     End If
  7. 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.
Feb 18 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 375
The RecordSet.RecordCount will be 0 if there are no records.
From the MainForm the syntax is:
Feb 18 '09 #2

P: 31
Thanks RuralGuy

That did the trick!
Feb 18 '09 #3

Expert 100+
P: 375
That's great! Glad I could help.
Feb 18 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.