Hide subform field's dafault value until needed

bongbang

Registered User.
Local time
Yesterday, 18:16
Joined
Dec 28, 2017
Messages
17
On my form, the default value of a subform field shows up on the New Entry row, even the row is not being edited. This is not only unsightly, but also misleading and confusing. Is there a way to have the subform's defaults show up only when they're needed (i.e. the new entry row is focused)?

Much to my surprise, I have not found others with this question in my more than cursory search.
 
This is what I do, you can modify it to suit.

You can hide a subform based on another field on the form. In this case, if my client is Active, certain pages or tabs appear, otherwise they don’t.

Code:
If Class = "Active" Then
   
      Me.SubForm1.Pages(1).Visible = True
      Me.SubForm1.Pages(4).Visible = True
      Me.SubForm1.Pages(5).Visible = True
      Me.SubForm1.Pages(9).Visible = True
      Me.SubForm1.Pages(10).Visible = True
      Me.SubForm1.Pages(11).Visible = True
   
  Else
      Me.SubForm1.Pages(1).Visible = True
      Me.SubForm1.Pages(4).Visible = False
      Me.SubForm1.Pages(5).Visible = False
      Me.SubForm1.Pages(9).Visible = True
      Me.SubForm1.Pages(10).Visible = False
      Me.SubForm1.Pages(11).Visible = False
  End If
Or, you can make the form blank by the following. It determines if there are any records.

Code:
  With Me![qryMainActiveSalesSub subform].Form
          .Visible = (.RecordsetClone.RecordCount > 0)
      End With
   
      With Me![frmMainInActiveSalesSub].Form
          .Visible = (.RecordsetClone.RecordCount > 0)
      End With
I use both, but on the second method, I have label under the subform on the tab that will either say “No Active Sales” or “No inactive sales”.
 

Users who are viewing this thread

Back
Top Bottom