If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Calculating Total
Hi there,
I run the following code: Private Sub FShare__Coke_2LtPET_Exit(Cancel As Integer) [FSha Total].Value = [FSha Total].OldValue - [FSha Coke 2LtPET].OldValue [FSha Total].Value = [FSha Total].Value + [FSha Coke 2LtPET].Value Form.Recalc If [FSha 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! |
#2
|
|||
|
|||
Calculating Total
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. "PsyberFox" wrote in message ... Hi there, I run the following code: Private Sub FShare__Coke_2LtPET_Exit(Cancel As Integer) [FSha Total].Value = [FSha Total].OldValue - [FSha Coke 2LtPET].OldValue [FSha Total].Value = [FSha Total].Value + [FSha Coke 2LtPET].Value Form.Recalc If [FSha 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! |
Thread Tools | |
Display Modes | |
|
|