Go Back   Access World Forums > Microsoft Access Discussion > Forms

Thread Tools Rate Thread Display Modes
Old 01-12-2018, 05:26 PM   #1
Newly Registered User
Join Date: Dec 2017
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
bongbang is on a distinguished road
Hide subform field's dafault value until needed

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.

bongbang is offline   Reply With Quote
Old 01-12-2018, 06:46 PM   #2
Still trying to learn
Join Date: Jan 2011
Location: Saratoga, California
Posts: 686
Thanks: 249
Thanked 29 Times in 29 Posts
Eljefegeneo is on a distinguished road
Re: Hide subform field's dafault value until needed

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.

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

  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”.
“To err is human, but to really foul things up you need a computer.”
Eljefegeneo is offline   Reply With Quote
Old 01-13-2018, 07:34 AM   #3
Pat Hartman
Super Moderator
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,448
Thanks: 13
Thanked 1,422 Times in 1,355 Posts
Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light
Re: Hide subform field's dafault value until needed

To hide the "new" record until you need it, set the form's "AllowAdditions" property to No. Add a button to the form to toggle this. When the button changes the property, have it go to the new record. In the AfterInsert event, you can reset the property to No if you want them to only insert one record or you can leave it set.

To use this method, you will probably have to set the AllowAdditions to No in the form's current event. That will reset it for each new record.

If you want to get fancy, you can set the enabled property of the button to No in its click event to prevent it from being clicked again and then set the enabled property to Yes in the form's AfterInsert event.

Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
The Following User Says Thank You to Pat Hartman For This Useful Post:
bongbang (01-13-2018)

default value , subform

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide/Show Subform if Value from form field not present in another table iseman22 Forms 3 05-11-2012 09:17 AM
Hide/Show Subform based on value in main form field iseman22 Forms 6 05-09-2012 07:39 AM
How to lock or hide a subform field cheer Forms 1 05-26-2011 11:34 PM
Hide footers when not needed tweetyksc Reports 1 06-13-2003 12:11 PM
hide subform based on field value lscheer Forms 1 11-07-2002 11:36 AM

All times are GMT -8. The time now is 10:54 PM.

Microsoft Access Help
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post

Sponsored Links

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World