Datasheet calculation of a field

V

VBAgroupie

Hi. I have a datasheet subform contained on a main form. I would like to
show the sum total of a cost field from the datasheet subform. I've tried
putting the sum field on the main form and the subform. If it is on the main
form I get Error# in the field value. If I put it on the subform I don't see
it. What am I doing wrong? Any help is appreciated. Thanks.

Also, I have another form where i was testing for duplicate input values
(error checking). If user types in a duplicate date it takes the record to
the record that has that value, but it still looks like I've typed in a
duplicate key value. How do I get rid of this problem. Thanks again.

Natalie
 
S

Steve Schapel

Natalie,

If you change the subform from datasheet to continuous view, you will be
able to see the sum control in the footer of the subform. If you really
want it to look like a datasheet, you can format the continuous view
form to look very similar to a datasheet appearance.

Otherwise, the idea of putting a control on the main form to reference
the subform total should work. The Control Source will be something
like this...
=[NameOfSubfromControl]![NameOfSumOfCostControl]
 
O

Ofer

1. Create a field on the footer of the subform with
=Sum(FieldName)

Create a field in the Main form with reference to the sum field in the sub
form
=[SubFormName].Form![SumFieldName]

2. The field where you type the date shouldn't be bounded to the field in
the table, when you type a date it will save it, and this is why you are
getting duplicates

Create a field that bound to the field in the table, not visible

Create an unbound field, where the user will input the date, on the after
update event of this field check if the date exist, if it exist, look for the
record.
If it doesn't exist move this date value to the real date field that is not
visible
Me.RealFieldName = Me.UnboundFieldName
 
Top