Subform Count onto main from and Table (1 Viewer)

stu_c

Registered User.
Local time
Today, 10:22
Joined
Sep 20, 2007
Messages
326
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!
 

Attachments

June7

AWF VIP
Local time
Today, 01:22
Joined
Mar 9, 2014
Messages
3,144
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?
 
Last edited:

stu_c

Registered User.
Local time
Today, 10:22
Joined
Sep 20, 2007
Messages
326
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 :)
 

vba_php

Forum Troll
Local time
Today, 04:22
Joined
Oct 6, 2019
Messages
2,884
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:
I really do need it in the table if possible, in this instance no the customer wont have more than one record
 

June7

AWF VIP
Local time
Today, 01:22
Joined
Mar 9, 2014
Messages
3,144
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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom