form field calculation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I hope some one can help i have a form thatis used for sales and i have a
total field that has the total of the sales. What i need now is a field where
i can enter the amount the customer gave me and it gives me the change amount
i need to give to the customer. But i want it to be like as i type in the
amount the customer gives me the change field must change it must be like
real time i dont want to go to a difrent field first before it gives the
change.

I hope some one can help
Markus
 
Markus,
An unbound text control (named [Change]) with a control source of... (use
your own names)
= AmountPaid - TotalSales
should show the Change due the customer upon entry of the AmountPaid amount.
hth
Al Camp
 
It does not work it gives me the change but what I need is as I type I am
typing in the amount the customer gives me it should change the [Change]
field at the moment it only changes it once I have confirmed the amount given
with Enter or my clicking on a different field I would like to be real time
if customer need to pay 10 Euro and I type the first character 2 for 20 Euro
before I can even enter the 0 it should already show in the change field that
I still have to give the -8 back and then as I am typing in the 0 for 20 Euro
it should show that I have to give 10 back

Thanks

Al Camp said:
Markus,
An unbound text control (named [Change]) with a control source of... (use
your own names)
= AmountPaid - TotalSales
should show the Change due the customer upon entry of the AmountPaid amount.
hth
Al Camp

Markus said:
I hope some one can help i have a form thatis used for sales and i have a
total field that has the total of the sales. What i need now is a field
where
i can enter the amount the customer gave me and it gives me the change
amount
i need to give to the customer. But i want it to be like as i type in the
amount the customer gives me the change field must change it must be like
real time i dont want to go to a difrent field first before it gives the
change.

I hope some one can help
Markus
 
It does not work it gives me the change but what I need is as I type I am
typing in the amount the customer gives me it should change the [Change]
field at the moment it only changes it once I have confirmed the amount given
with Enter or my clicking on a different field I would like to be real time
if customer need to pay 10 Euro and I type the first character 2 for 20 Euro
before I can even enter the 0 it should already show in the change field that
I still have to give the -8 back and then as I am typing in the 0 for 20 Euro
it should show that I have to give 10 back

Update the Change field in the Change event of the AmountPaid textbox:

Private Sub AmountPaid_Change()
Me![Change] = NZ(Me!AmountPaid) - Me!TotalSales
End Sub

John W. Vinson[MVP]
 
Hi John

I tryd it it does not work i enter it and the field where i enter the amount
the customer gives me as soon as i type in the first character of the amount
the change field changes and shoes the total and as soon as i type in the
second character nothing happends it does not change again even if i type
with the first charect it does not calculate correctly

in the change field i removed the control source code i had there before.

I hope you have more ideas

Markus

John Vinson said:
It does not work it gives me the change but what I need is as I type I am
typing in the amount the customer gives me it should change the [Change]
field at the moment it only changes it once I have confirmed the amount given
with Enter or my clicking on a different field I would like to be real time
if customer need to pay 10 Euro and I type the first character 2 for 20 Euro
before I can even enter the 0 it should already show in the change field that
I still have to give the -8 back and then as I am typing in the 0 for 20 Euro
it should show that I have to give 10 back

Update the Change field in the Change event of the AmountPaid textbox:

Private Sub AmountPaid_Change()
Me![Change] = NZ(Me!AmountPaid) - Me!TotalSales
End Sub

John W. Vinson[MVP]
 
Hi John

I tryd it it does not work i enter it and the field where i enter the amount
the customer gives me as soon as i type in the first character of the amount
the change field changes and shoes the total and as soon as i type in the
second character nothing happends it does not change again even if i type
with the first charect it does not calculate correctly

in the change field i removed the control source code i had there before.

Please copy and paste your actual code; indicate the names of the
relevant form controls.

John W. Vinson[MVP]
 
Ihave 3 field

1 Total
2 Paid ( the amount the customer gives me which get enterd)
3 Change ( The change calculated)

Paid
has the code in the on change field
Private Sub Paid_Change()

Me![Change] = Nz(Me![Paid]) - Me![Total]

End Sub

On the Change field there is no code on it at all and no control source

markus
 
Ihave 3 field

1 Total
2 Paid ( the amount the customer gives me which get enterd)
3 Change ( The change calculated)

Paid
has the code in the on change field
Private Sub Paid_Change()

Me![Change] = Nz(Me![Paid]) - Me![Total]

End Sub

I'd suggest that you <ahem> change the name of Change. Access may be
getting confused between the Change *event* and the Change *control*.
Try renaming the textbox to ChangeDue. I guess you'll also need to use
the Paid textbox's Text property (the unsaved "live" value) rather
than its default Value property. The Change event of Paid might then
be

Private Sub Paid_Change()
Me!ChangeDue = NZ(Me![Paid].Text) - Me![Total]
ENd Sub


John W. Vinson[MVP]
 
John

It work perfectly now thank you

Markus

John Vinson said:
Ihave 3 field

1 Total
2 Paid ( the amount the customer gives me which get enterd)
3 Change ( The change calculated)

Paid
has the code in the on change field
Private Sub Paid_Change()

Me![Change] = Nz(Me![Paid]) - Me![Total]

End Sub

I'd suggest that you <ahem> change the name of Change. Access may be
getting confused between the Change *event* and the Change *control*.
Try renaming the textbox to ChangeDue. I guess you'll also need to use
the Paid textbox's Text property (the unsaved "live" value) rather
than its default Value property. The Change event of Paid might then
be

Private Sub Paid_Change()
Me!ChangeDue = NZ(Me![Paid].Text) - Me![Total]
ENd Sub


John W. Vinson[MVP]
 
Back
Top