Solved

Subform to show the form according to how many records

Posted on 2014-12-10
5
197 Views
Last Modified: 2014-12-11
Sorry for all the questions...How can you set the subform to show the form if it only has two records and expand if it has twenty records?  Is there a setting for that or do you have to write code..either way please explain
0
Comment
Question by:Jass Saini
5 Comments
 
LVL 23

Accepted Solution

by:
Eirman earned 500 total points
ID: 40492820
Assuming that there is a one to many relationship between the tables
that are behind the main form and the subform then ...

Provided the subform is a continuous form (or datasheet), all records
(1 or 2 or 20 or 200 etc.) will show in the subform.
Just make sure the subform is big enough and has a vertical scrollbar - Nothing needs to expand.

No coding is needed for this.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40492864
To me it is not really practical to Hide/show the subform, ...because of the code needed to check for existing records.
Also hiding/showing controls is a confusing interface for users. (They will wonder why sometimes they see the subform and sometimes not...)
There are other reasons as well...
Like the fact that you may have to "unhide" it if you need to add a subform record.
Standard design rules say that you always display the subform, when there are no records, ...it will be empty.

Eirman, has addressed your design and "expand" issues.

;-)

JeffCoachman
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40492878
Although I generally agree with Jeff's comment:
"Standard design rules say that you always display the subform, when there are no records, ...it will be empty."

I will occasionally violate this rule if the contents of the subform is based on multiple selectable values on the main form.  For example, I frequently use subforms to display datasheets or continuous forms which are based on a query, and are not bound by a parent/child relationship on the main form.  When I do this, I will generally hide the subform when a user changes a selection in one of the controls which define the query results, so that if the user gets distracted and comes back to his computer, he/she does not think that the information displayed in the subform is reflective of the selectable parameters.  In this case, if any of the controls in the main form are changed, I hide the subform until such time as the user clicks the "Update" button on the main form.
0
 

Author Closing Comment

by:Jass Saini
ID: 40494153
Thank you
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 40494154
You can make the form sizable by adding fourlines of code to the main form's resize event.
Private Sub Form_Resize()
    Const LeftRightPadding = (0.125 + 0.25) * 1440
    Const TopBottomPadding = (0.68 + 0.45) * 1440
    
    Me.sfrmFindRejects.Height = Me.InsideHeight - TopBottomPadding
    Me.sfrmFindRejects.Width = Me.InsideWidth - LeftRightPadding
End Sub

Open in new window

You'll have to play with the constants because the values that work will be dependent on the size of the form's header and footer and where on the form the subform is.
SmallerLarger
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
corrupt Databases 9 64
Insert Into syntax error 10 29
table joins in qry 17 61
Access 2010 change CurrentUser 5 33
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question