?
Solved

Subform to show the form according to how many records

Posted on 2014-12-10
5
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 24

Accepted Solution

by:
Eirman earned 2000 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 48

Expert Comment

by:Dale Fye
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 38

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

752 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