Full Version: Basic Addition!
UtterAccess Forums > Microsoft® Access > Access Forms
AndrewHealey
This is a really dumb question i think but im learning as i go! How do i add up values on a form? i've got 6 different scrap reasons which will be entered but i need a total scrap value to be displayed on the form and in reports and preferably actually in the table so that i can analyse it elsewhere.
Thanks
andy
dannyseager
in the control source of a text box (on the data tab of the controls properties)
[field1] + [field2] + [field3] + [field4] + [field5] + [field6]
AndrewHealey
i've tried this but all i get is the equivalant to =concanate (sp?) in excel, if i've got 1 in a field and 2 in another it gives me 12 rather then 3!
ndy
Chaga
Try Val([field1]) + ... or Int([Field1]) + ...
TH
AndrewHealey
same result with both :(
Chaga
Did you use Val([field1]) + Val([field2]) + Val([Field3]) + ... ???
AndrewHealey
/me kicks self
fs! i've spent ages trying to find the solution! i had all the fields as text rather then number in the table!
sorry!
andy
Chaga
I noticed that, and that's why I proposed the Val() function. It converts any number in a string to number.
AndrewHealey
ummm now im getting #error is that a settings related error u think?
Chaga
Hmmm, I have a feeling you are adding these values in a table field; am I correct?
AndrewHealey
nah its on the form
Chaga
Can you post a stripped version of your DB?
Just the form with it's related table and a couple of records.
AndrewHealey
uploaded it if u fancy a look... its the booking form sheet
dont laugh! its my first database!
andy
AndrewHealey
soz its all there but not very big. if u can sort my delete button too while your there! oh and my....... laugh.gif
ts for a touch screen system im setting up at work.
thanks
andy
AndrewHealey
i've just noticed its working on new records just not the ones already there, which isnt a problem as its only false data.
Chaga
/>Well it's much better than my first database.
You still need to normalize your DB a little (you have some repeating groups), you can read about normalization in the Access FAQAs forum here in UA.
HAs for your problem you'll need to use the Nz() function to replace Nulls with zeroes.
Do a search on it in Access Help for further info.
You use it the following way:
Nz([Field1]) + Nz([Field2]) + .... Assuming you changed all your fields from text to number.
HTH
AndrewHealey
cheers mate. theres still alot i need to do especially with reports - need run rates and loads of stuff like that and to be honest i think when i've worked out how to do it all i mite go back to the beggining and start it from new. see how it goes anyway. if u have got any hints for that backspace button by the number pad on the same form it wud be much appreciated! frown.gif
Thanks again
andy
Chaga
one approach could be like that:
pre>Private Sub cmdDelete_Click()
Me(strCtl).SetFocus
Me(strCtl).SelStart = Len(Me(strCtl))
SendKeys "{BS}"
End Sub

You can also use another approach with the Left() and Len() functions.
AndrewHealey
supurb!
a very much! i was trying the approach of the sendkey but cudnt find out what backspace was to code!
cheers
andy
Chaga
You're welcome wink.gif, glad to help.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.