Solved

Passing a variable betweent forms

Posted on 2012-12-29
4
202 Views
Last Modified: 2012-12-29
Good morning,

I have a primary form with a subform housing records based on criteria in the header of the main form.

I also want to include a text box into my main form which would display the record count in the subform.  Can I have some ideas on how to handle this?
0
Comment
Question by:MCaliebe
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 38729318
Add a control to the Footer of the Subform, and set this as the ControlSource:

=Count(*)

Include the = sign too ...

Name that control "txSFCount"

Now in the mainform, add your table and set the ControlSource like this:

=Me.NameOfYourSubformCONTROL.Form.txSFCount

Note that NameOfYourSubformCONTROL is the name of the Subform CONTROL on the mainform, and may or may not be the same as the form you're using as a subform.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 38729322
Add a textbox into the Form footer of the subform and set the controlsource to ...

=Count([anyNotNullField])
Say this textbox is called txtCount.

In the main form header add a textbox with the controlsource of...
=forms!mainformname!subformcontainername.Form!txtCount

subformcontainername is the name of the subform control on the main form that holds the subform.  It might be the same name as the subform but if they are different it is the subform (container) control name that must be used,
0
 

Author Comment

by:MCaliebe
ID: 38729615
This gets me my count, however how do I get a 0 when no records exists.  Currently, the count text box in my sub form foote is blank and the reporting text box in my main form is Error.
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 38729623
Use an IIF statement, something like:

=Iif(IsNumeric(Me.YourSubform.Form.txSFCount, Me.YourSubform.Form.txSFCount,0)
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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