A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calculating Total



 
 
Thread Tools Display Modes
  #1  
Old November 28th, 2009, 12:15 PM posted to microsoft.public.access.forms
PsyberFox
external usenet poster
 
Posts: 88
Default 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  
Old November 28th, 2009, 12:58 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.