Solved

Passing a variable betweent forms

Posted on 2012-12-29
4
204 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
[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
  • 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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