Copy a result of calculated control to another field

T

TKI

I have a an Invoice form that allows the user to enter in invoice detail by
consultant. Once they select a consultant, hours and rate are entered and a
total fee amount is calculated. I need to take the fee amount and copy it to
the Amount Paid field, which is in the same table as the stored consultant
information. I tried using a setvalue macro but it didn't work. Any ideas?
The reason I want to do this is because the user then needs to fill out
another form where he can change the amount paid field if he is not going to
pay the exact calculated fee amount.
 
J

John W. Vinson

I have a an Invoice form that allows the user to enter in invoice detail by
consultant. Once they select a consultant, hours and rate are entered and a
total fee amount is calculated. I need to take the fee amount and copy it to
the Amount Paid field, which is in the same table as the stored consultant
information. I tried using a setvalue macro but it didn't work. Any ideas?
The reason I want to do this is because the user then needs to fill out
another form where he can change the amount paid field if he is not going to
pay the exact calculated fee amount.

I'd use VBA code in the AfterUpdate event of the form, or the click event of
the command button which does the calculation (if there is such a button).

You don't say whether the consultant information table is part of this form's
recordsource. If it is then the code could simply be

Me!txtConsultantFee = Me!txtCalcFee

using the actual control names of course; if not, you may need to open a
recordset on the table. More info please!
 
T

TKI

Yes, the Amount Paid field is a part of the form's record source as are the
Hours, Rate, and Fee. The Fee, however, is a calculated field that
multiplies rate and hours. So, once the consultant name, hours, and rate are
entered, the fee is calculated. Once calculated, I need the fee amount to be
copied to the amount paid field. The reason why I want to do this is so that
user doesn't have to manually type in the amount paid. The user will only
need to edit the amount paid field if it differs from the fee amount - which
is rare.
 
J

John W. Vinson

Yes, the Amount Paid field is a part of the form's record source as are the
Hours, Rate, and Fee. The Fee, however, is a calculated field that
multiplies rate and hours. So, once the consultant name, hours, and rate are
entered, the fee is calculated. Once calculated, I need the fee amount to be
copied to the amount paid field. The reason why I want to do this is so that
user doesn't have to manually type in the amount paid. The user will only
need to edit the amount paid field if it differs from the fee amount - which
is rare.

So.... is it working?

I did ask for form and control names. I'll be glad to help with the code if
need be but I can't see your form from here.
 
T

TKI

The form, called Subform1, has a recordsource called Subform1 Query. In the
query, the fee is a calculated field that automatically calculates when rate
and hours are entered. On the form, the text box is called Fee. The other
text box on the form is called Amount Paid.
 
J

John W. Vinson

The form, called Subform1, has a recordsource called Subform1 Query. In the
query, the fee is a calculated field that automatically calculates when rate
and hours are entered. On the form, the text box is called Fee. The other
text box on the form is called Amount Paid.

Then put code in Subform1's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
<do any validation checking first>
If Not IsNull(Me!Fee) Then
Me![Amount Paid] = Me!Fee
End If
End Sub
 

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