Summing Calculated Control

R

Ron Weaver

Although I have read the posts on this, I still can't get it to work. I have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes" is code in
the module. It converts the time to hours and minutes. This works on the
form. I need to sum this in the forms header and multiply it times the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate]. What do I
need to do? Thanks
 
J

Jeanette Cunningham

Ron,
If you are on the parent form and want to know the value of a control on the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the name of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham
 
R

Ron Weaver

Jeanette, thanks so much for your reply. I wil try to clarify this a bit.
This is all on a subform. Billable Hours were manually input before. I added
Arrive Time and Depart Time because they wanted a record of this. Then in the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each job.
Now I need to sum this in the form header so it can be used in other areas. I
hope this gives you a better idea of what I am trying to do. I can't get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]), but
couldn't get it to work. Thanks for any help.

Jeanette Cunningham said:
Ron,
If you are on the parent form and want to know the value of a control on the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the name of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Ron Weaver said:
Although I have read the posts on this, I still can't get it to work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes" is code
in
the module. It converts the time to hours and minutes. This works on the
form. I need to sum this in the forms header and multiply it times the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate]. What do I
need to do? Thanks
 
J

Jeanette Cunningham

Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Ron Weaver said:
Jeanette, thanks so much for your reply. I wil try to clarify this a bit.
This is all on a subform. Billable Hours were manually input before. I
added
Arrive Time and Depart Time because they wanted a record of this. Then in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]), but
couldn't get it to work. Thanks for any help.

Jeanette Cunningham said:
Ron,
If you are on the parent form and want to know the value of a control on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Ron Weaver said:
Although I have read the posts on this, I still can't get it to work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes" is
code
in
the module. It converts the time to hours and minutes. This works on
the
form. I need to sum this in the forms header and multiply it times the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate]. What do
I
need to do? Thanks
 
R

Ron Weaver

Jeanette,
I tried the first code you suggested and got an error. If I use just
=[txtBillableHours] I get a number of hours, but they are totally wrong. The
other code read error also. I guess that it's because [txtBillableHours]
contains a calculation. I don't know how to work around it. Thanks for taking
your time to help.

Jeanette Cunningham said:
Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Ron Weaver said:
Jeanette, thanks so much for your reply. I wil try to clarify this a bit.
This is all on a subform. Billable Hours were manually input before. I
added
Arrive Time and Depart Time because they wanted a record of this. Then in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]), but
couldn't get it to work. Thanks for any help.

Jeanette Cunningham said:
Ron,
If you are on the parent form and want to know the value of a control on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Although I have read the posts on this, I still can't get it to work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes" is
code
in
the module. It converts the time to hours and minutes. This works on
the
form. I need to sum this in the forms header and multiply it times the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate]. What do
I
need to do? Thanks
 
J

Jeanette Cunningham

Ron,
please post what you currently have for the control source for
txtBillableHours

Jeanette Cunningham


Ron Weaver said:
Jeanette,
I tried the first code you suggested and got an error. If I use just
=[txtBillableHours] I get a number of hours, but they are totally wrong.
The
other code read error also. I guess that it's because [txtBillableHours]
contains a calculation. I don't know how to work around it. Thanks for
taking
your time to help.

Jeanette Cunningham said:
Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Ron Weaver said:
Jeanette, thanks so much for your reply. I wil try to clarify this a
bit.
This is all on a subform. Billable Hours were manually input before. I
added
Arrive Time and Depart Time because they wanted a record of this. Then
in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each
job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't
get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]), but
couldn't get it to work. Thanks for any help.

:

Ron,
If you are on the parent form and want to know the value of a control
on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the
name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Although I have read the posts on this, I still can't get it to
work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes" is
code
in
the module. It converts the time to hours and minutes. This works on
the
form. I need to sum this in the forms header and multiply it times
the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate]. What
do
I
need to do? Thanks
 
J

Jeanette Cunningham

Ron,
also please post the code that calculates hours and minutes, as you
mentioned previously.
I assume that the text box called txtBillableHours does show the correct
value for hours and minutes for each row of the subform?

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
please post what you currently have for the control source for
txtBillableHours

Jeanette Cunningham


Ron Weaver said:
Jeanette,
I tried the first code you suggested and got an error. If I use just
=[txtBillableHours] I get a number of hours, but they are totally wrong.
The
other code read error also. I guess that it's because [txtBillableHours]
contains a calculation. I don't know how to work around it. Thanks for
taking
your time to help.

Jeanette Cunningham said:
Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Jeanette, thanks so much for your reply. I wil try to clarify this a
bit.
This is all on a subform. Billable Hours were manually input before. I
added
Arrive Time and Depart Time because they wanted a record of this. Then
in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each
job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't
get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]), but
couldn't get it to work. Thanks for any help.

:

Ron,
If you are on the parent form and want to know the value of a control
on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the
name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Although I have read the posts on this, I still can't get it to
work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes"
is
code
in
the module. It converts the time to hours and minutes. This works
on
the
form. I need to sum this in the forms header and multiply it times
the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate].
What do
I
need to do? Thanks
 
J

Jeanette Cunningham

Ron,
I have set up a table and a form to test this. Here is what I have.
tblTimes with 3 fields, StartTime and EndTime, both date time fields with
format set to General Date time.
3rd field is BillingRate -- Number field as single.

On the form a text box each for start time and end time and billing rate
An unbound text box txtTotalTime -- Control source =
IIf(DateDiff("n",[StartTime],[EndTime]) Mod
60=0,DateDiff("h",[StartTime],[EndTime]),DateDiff("n",[StartTime],[EndTime])/60)

A text box txtTotalAmount -- Control source = [txtTotalTime]*[BillingRate]

When you change the billing rate, the TotalAmount recalculates.

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
also please post the code that calculates hours and minutes, as you
mentioned previously.
I assume that the text box called txtBillableHours does show the correct
value for hours and minutes for each row of the subform?

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
please post what you currently have for the control source for
txtBillableHours

Jeanette Cunningham


Ron Weaver said:
Jeanette,
I tried the first code you suggested and got an error. If I use just
=[txtBillableHours] I get a number of hours, but they are totally wrong.
The
other code read error also. I guess that it's because [txtBillableHours]
contains a calculation. I don't know how to work around it. Thanks for
taking
your time to help.

:

Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Jeanette, thanks so much for your reply. I wil try to clarify this a
bit.
This is all on a subform. Billable Hours were manually input before.
I
added
Arrive Time and Depart Time because they wanted a record of this.
Then in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each
job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't
get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]),
but
couldn't get it to work. Thanks for any help.

:

Ron,
If you are on the parent form and want to know the value of a
control on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the
name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Although I have read the posts on this, I still can't get it to
work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes"
is
code
in
the module. It converts the time to hours and minutes. This works
on
the
form. I need to sum this in the forms header and multiply it times
the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate].
What do
I
need to do? Thanks
 
R

Ron Weaver

Jeanette,

That works fine for a single entry of StartTime/EndTime. I need to SUM the
[txtTotalTime] to include multiple StartTime/EndTime entries. When I do the
=Sum([txtTotalTime]*[BillingRate]), I get "ERROR". This text box
(txtTotalAmount), is in the header of the subform.
Again, thanks for your help!

Jeanette Cunningham said:
Ron,
I have set up a table and a form to test this. Here is what I have.
tblTimes with 3 fields, StartTime and EndTime, both date time fields with
format set to General Date time.
3rd field is BillingRate -- Number field as single.

On the form a text box each for start time and end time and billing rate
An unbound text box txtTotalTime -- Control source =
IIf(DateDiff("n",[StartTime],[EndTime]) Mod
60=0,DateDiff("h",[StartTime],[EndTime]),DateDiff("n",[StartTime],[EndTime])/60)

A text box txtTotalAmount -- Control source = [txtTotalTime]*[BillingRate]

When you change the billing rate, the TotalAmount recalculates.

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
also please post the code that calculates hours and minutes, as you
mentioned previously.
I assume that the text box called txtBillableHours does show the correct
value for hours and minutes for each row of the subform?

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
please post what you currently have for the control source for
txtBillableHours

Jeanette Cunningham


Jeanette,
I tried the first code you suggested and got an error. If I use just
=[txtBillableHours] I get a number of hours, but they are totally wrong.
The
other code read error also. I guess that it's because [txtBillableHours]
contains a calculation. I don't know how to work around it. Thanks for
taking
your time to help.

:

Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Jeanette, thanks so much for your reply. I wil try to clarify this a
bit.
This is all on a subform. Billable Hours were manually input before.
I
added
Arrive Time and Depart Time because they wanted a record of this.
Then in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each
job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't
get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]),
but
couldn't get it to work. Thanks for any help.

:

Ron,
If you are on the parent form and want to know the value of a
control on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the
name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Although I have read the posts on this, I still can't get it to
work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes"
is
code
in
the module. It converts the time to hours and minutes. This works
on
the
form. I need to sum this in the forms header and multiply it times
the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate].
What do
I
need to do? Thanks
 
R

Ron Weaver

Jeanette<
I finally got this to work By putting this code in the 'txtTotalAmount'
Control Source: Sum(IIf(DateDiff("n",[ArriveTime],[DepartTime]) Mod
60=0,DateDiff("h",[ArriveTime],[DepartTime]),DateDiff("n",[ArriveTime],[DepartTime])/60)*[BillingRate]
This form works now. Unfortuately this messes with another form which is
looking for the Record Source 'BillableHours' as part of an expression in a
Query. This Record Source is now a calculation. I tried replacing
'BillableHours' in the Query Expression with the code that is now in the
Record Source of 'BillableHours': 'IIf(DateDiff("n",[StartTime],[EndTime])
Mod
60=0,DateDiff("h",[StartTime],[EndTime]),DateDiff("n",[StartTime],[EndTime])/60)', but that didn't work.
I know you didn't take me to raise. Thanks for what you have done.


Jeanette Cunningham said:
Ron,
I have set up a table and a form to test this. Here is what I have.
tblTimes with 3 fields, StartTime and EndTime, both date time fields with
format set to General Date time.
3rd field is BillingRate -- Number field as single.

On the form a text box each for start time and end time and billing rate
An unbound text box txtTotalTime -- Control source =
IIf(DateDiff("n",[StartTime],[EndTime]) Mod
60=0,DateDiff("h",[StartTime],[EndTime]),DateDiff("n",[StartTime],[EndTime])/60)

A text box txtTotalAmount -- Control source = [txtTotalTime]*[BillingRate]

When you change the billing rate, the TotalAmount recalculates.

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
also please post the code that calculates hours and minutes, as you
mentioned previously.
I assume that the text box called txtBillableHours does show the correct
value for hours and minutes for each row of the subform?

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
please post what you currently have for the control source for
txtBillableHours

Jeanette Cunningham


Jeanette,
I tried the first code you suggested and got an error. If I use just
=[txtBillableHours] I get a number of hours, but they are totally wrong.
The
other code read error also. I guess that it's because [txtBillableHours]
contains a calculation. I don't know how to work around it. Thanks for
taking
your time to help.

:

Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Jeanette, thanks so much for your reply. I wil try to clarify this a
bit.
This is all on a subform. Billable Hours were manually input before.
I
added
Arrive Time and Depart Time because they wanted a record of this.
Then in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each
job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't
get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]),
but
couldn't get it to work. Thanks for any help.

:

Ron,
If you are on the parent form and want to know the value of a
control on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the
name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Although I have read the posts on this, I still can't get it to
work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes"
is
code
in
the module. It converts the time to hours and minutes. This works
on
the
form. I need to sum this in the forms header and multiply it times
the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate].
What do
I
need to do? Thanks
 
R

Ron Weaver

I FIXED IT! I went to the Query causing the problem and removed the field
with the expression [BillableHours]*[BillingRate]. I then added the field
'BillingRate' with "Group By" on the Totals line. Next I created a field with
the expression: =Sum(IIf(DateDiff("n",[ArriveTime],[DepartTime]) Mod
60=0,DateDiff("h",[ArriveTime],[DepartTime]),DateDiff("n",[ArriveTime],[DepartTime])/60))*[BillingRate].
I then replaced "expr1" with the original name, 'Labor Total'. Everything
works now.
Thanks again!!

Jeanette Cunningham said:
Ron,
I have set up a table and a form to test this. Here is what I have.
tblTimes with 3 fields, StartTime and EndTime, both date time fields with
format set to General Date time.
3rd field is BillingRate -- Number field as single.

On the form a text box each for start time and end time and billing rate
An unbound text box txtTotalTime -- Control source =
IIf(DateDiff("n",[StartTime],[EndTime]) Mod
60=0,DateDiff("h",[StartTime],[EndTime]),DateDiff("n",[StartTime],[EndTime])/60)

A text box txtTotalAmount -- Control source = [txtTotalTime]*[BillingRate]

When you change the billing rate, the TotalAmount recalculates.

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
also please post the code that calculates hours and minutes, as you
mentioned previously.
I assume that the text box called txtBillableHours does show the correct
value for hours and minutes for each row of the subform?

Jeanette Cunningham


Jeanette Cunningham said:
Ron,
please post what you currently have for the control source for
txtBillableHours

Jeanette Cunningham


Jeanette,
I tried the first code you suggested and got an error. If I use just
=[txtBillableHours] I get a number of hours, but they are totally wrong.
The
other code read error also. I guess that it's because [txtBillableHours]
contains a calculation. I don't know how to work around it. Thanks for
taking
your time to help.

:

Ron,
try
= Sum(Me.txtBillableHours)

Or

= Nz(Sum(Me.txtBillableHours)*Me.txtBillingRate, 0)

txtBillableHours is name of control for billable hours
txtBillingRate is name of control for billing rate

Replace above control names with your control names.

Jeanette Cunningham

Jeanette, thanks so much for your reply. I wil try to clarify this a
bit.
This is all on a subform. Billable Hours were manually input before.
I
added
Arrive Time and Depart Time because they wanted a record of this.
Then in
the
record source of the Billable Hours (txtBillableHours) I put the
HoursAndMinutes([DepartTime]-[ArriveTime]), so it would total on each
job.
Now I need to sum this in the form header so it can be used in other
areas. I
hope this gives you a better idea of what I am trying to do. I can't
get
anything to work. I tried: =Sum([txtBillableHours]*[BillingRate]),
but
couldn't get it to work. Thanks for any help.

:

Ron,
If you are on the parent form and want to know the value of a
control on
the
subform, use syntax like this
Me.[MainFormControl] =
Me.[NameOfSubformControlOnMainForm].Form.[ControlNameOnSubform]
Note that NameOfSubformControlOnMainForm is often different from the
name
of
the subform inside the subform control.

It looks like you need to create the sum of hours and minutes on the
subform
Use an unbound text box called txtTheSum with control source =
Sum([NameOfHrsAndMinsControl])
I assume that [BillingRate] is a field or control on the main form?

Back on the main form
= Me.Nz([NameOfSubformControlOnMainForm].Form.txtTheSum,
0)*[BillingRate]

Jeanette Cunningham

Although I have read the posts on this, I still can't get it to
work. I
have
put the following code into the subform control's record source:
HoursAndMinutes([DepartTime]-[ArriveTime]). The "HoursAndMinutes"
is
code
in
the module. It converts the time to hours and minutes. This works
on
the
form. I need to sum this in the forms header and multiply it times
the
billing rate. I have tried:
=Sum(HoursAndMinutes([DepartTime]-[ArriveTime]))*[BillingRate].
What do
I
need to do? Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top