A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

MS Access 2007: Calculated field based on subform:



 
 
Thread Tools Display Modes
  #1  
Old May 14th, 2010, 03:38 AM posted to microsoft.public.access.forms
mmullins
external usenet poster
 
Posts: 1
Default MS Access 2007: Calculated field based on subform:

Hello:

As part of a review assignment, I have been tasked with adding a calculated
field to a form that will count the number of items listed in the associated
subform. The subform is based on the table "tblProduct", and is a subform
named "frmProductSubform". The Parent table is named "tblCompany".

The tables are related by ProductID, and CustomerID fields. The fields
included in the subform a ProductID, ProductType, Price, and Unit.

I am trying to create a calculated field based on the subform that will
count the number of line items in the subform for the Parent table Customer
record. I have added a text field to the Parent table's detail section named
"Number of Products", and attempted to build an expression
"=Count([ProductID])" to count the records in the related subform, but all I
get is "error".

What am I missing here?



--
PstBy: mmullins/mlm with humble regards to all...
  #2  
Old May 14th, 2010, 03:59 AM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default MS Access 2007: Calculated field based on subform:

"mmullins" wrote in message
...
Hello:

As part of a review assignment, I have been tasked with adding a
calculated
field to a form that will count the number of items listed in the
associated
subform. The subform is based on the table "tblProduct", and is a subform
named "frmProductSubform". The Parent table is named "tblCompany".

The tables are related by ProductID, and CustomerID fields. The fields
included in the subform a ProductID, ProductType, Price, and Unit.

I am trying to create a calculated field based on the subform that will
count the number of line items in the subform for the Parent table
Customer
record. I have added a text field to the Parent table's detail section
named
"Number of Products", and attempted to build an expression
"=Count([ProductID])" to count the records in the related subform, but all
I
get is "error".

What am I missing here?



Try setting the ControlSource of your [Number of Products] text box to:

=[frmProductSubform].[Form].[Recordset].[RecordCount]

Note that this assumes that the subform control (on the main form) is
actually named "frmProductSubform" -- it may not be, even if it is
displaying the form that has that name.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.