Solved

Subform to show the form according to how many records

Posted on 2014-12-10
5
195 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
Comment Utility
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
Comment Utility
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)
Comment Utility
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
Comment Utility
Thank you
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

728 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

10 Experts available now in Live!

Get 1:1 Help Now