Calculating Total

P

PsyberFox

Hi there,
I run the following code:
Private Sub FShare__Coke_2LtPET_Exit(Cancel As Integer)
[FShare: Total].Value = [FShare: Total].OldValue - [FShare: Coke
2LtPET].OldValue
[FShare: Total].Value = [FShare: Total].Value + [FShare: Coke
2LtPET].Value
Form.Recalc

If [FShare: Coke 2LtPET].Value = 0 And [Price: Coke 2LtPET] <> 0 Then
result = MsgBox("Price info entered - needs F Share info", vbOKOnly)
Cancel = True
End If

End Sub

However, for some reason the result blanks out any information in this field
after this function is run. When i manually put in a value after I've entered
data, the function works 100%, but not for new records. I have set the
default value for this field to 0, and even tried to do a calc on form load,
but still no luck.

Can someone please help!

Thank you!
 
J

Jeff Boyce

Setting the default value in a field doesn't change existing records'
values. To do that, use an update query. (NOTE: backup, backup, backup!
update queries change data.)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

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