Solved

Subform to show the form according to how many records

Posted on 2014-12-10
5
196 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 5 53
Access 2016 - Labels prompt to print 4 30
vba sql wild card passing in code 3 20
Any Way to Print an Import Spec? 3 28
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

816 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now