Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-13-2019, 12:52 AM   #1
stu_c
Newly Registered User
 
Join Date: Sep 2007
Posts: 278
Thanks: 7
Thanked 1 Time in 1 Post
stu_c is on a distinguished road
Subform Count onto main from and Table

Hi all
I have a Subform within a main form I need a textbox on the main form that calculates a total number of records in the sub form and needs to save to the main table, I have tried a few different methods without any success, I have even tried calculating the record numbers on the SubForm and then showing the number on the main form but cannot get it to show on the table.

I have made a very basic form of the two ways I have tried any suggestions would be great!
Attached Files
File Type: accdb TestDatabase1.accdb (640.0 KB, 9 views)
File Type: accdb TestDatabase1A.accdb (744.0 KB, 7 views)

stu_c is offline   Reply With Quote
Old 11-13-2019, 01:17 AM   #2
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,473
Thanks: 0
Thanked 575 Times in 571 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Subform Count onto main from and Table

Saving aggregate data is usually ill-advised. Just calculate when needed. Why do you need to save to table?

DB 1A is correct way to calculate and display this data. Code (VBA or macro) can save to field on main form. Real trick is figuring out what event to use. But again, advise not to save.

Won't customers have more than one order?
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by June7; 11-13-2019 at 01:42 PM.
June7 is online now   Reply With Quote
Old 11-13-2019, 02:44 AM   #3
stu_c
Newly Registered User
 
Join Date: Sep 2007
Posts: 278
Thanks: 7
Thanked 1 Time in 1 Post
stu_c is on a distinguished road
Re: Subform Count onto main from and Table

Quote:
Originally Posted by June7 View Post
Saving aggregate data is usually ill-advised. Just calculate when needed. Why do you need to save to table?

DB 1A is correct way to calculated and display this data. Code (VBA or macro) can save to field on main form. Real trick is figuring out what event to use. But again, advise not to save.

Won't customers have more than one order?
Hello June
thank you for the reply, I really do need it in the table if possible, in this instance no the customer wont have more than one record

stu_c is offline   Reply With Quote
Old 11-13-2019, 01:15 PM   #4
vba_php
Software Engineer
 
vba_php's Avatar
 
Join Date: Oct 2019
Location: Iowa City, IA, USA
Posts: 651
Thanks: 79
Thanked 77 Times in 77 Posts
vba_php is on a distinguished road
Re: Subform Count onto main from and Table

Quote:
Saving aggregate data is usually ill-advised
is saving a simple record count really classified as "aggregate data"? I thought that was like financials, maths and stuff. avg, sum, etc...?

how about writing a query that gives one field in one record, with a recordcount of the subform records?

but like June said, why do you need this in a table? that really doesn't make sense, even after saying:
Quote:
I really do need it in the table if possible, in this instance no the customer wont have more than one record
vba_php is offline   Reply With Quote
Old 11-13-2019, 01:49 PM   #5
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,473
Thanks: 0
Thanked 575 Times in 571 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Subform Count onto main from and Table

OP wants a total of number of items in an order. That is an aggregate calc. Count() should work in this case because apparently each item of order is a presumed quantity of 1 since there is no Quantity field.

Really, customer never makes another order?

Could try form BeforeUpdate event to save value: Me!fieldname = Me.textboxname

Me!TotalNumberOfItemsBought = Me.TotalNumberOfItemsBought

__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SubForm/table filtering main form Lenovo123 Forms 10 12-14-2015 07:35 AM
subform datasheet to populate main table penfold1992 Forms 4 05-20-2014 05:38 AM
Count Subform Datasheet Records on Main Form dukquack Forms 3 01-13-2013 06:32 PM
Subform Record Count displayed on main form Garindan Forms 17 02-18-2011 07:27 AM
Main Form to Add New Record onto subform / table Lancer Forms 2 02-12-2003 03:27 PM




All times are GMT -8. The time now is 03:07 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World