Link to home
Start Free TrialLog in
Avatar of Jass Saini
Jass Saini

asked on

Adding field together

I need to add field1 and feild2 into field3...is that better to make field3 a calculated field or doing it on the form.  If it's better on the form...where on the form??
SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jass Saini
Jass Saini

ASKER

So I am sorry where in the query should I do this
Hello Pat,

Sorry.... I was using a query.  But I could find how to input into my blank fields, so now I am using a master/child form.  I need to make the calculation field in the subform
using a subform doesn't change the suggestion.  Every form should use a query as its RecordSource.

If you insist on putting the calculation in the subform, add the following to the ControlSource for field3

=Nz(fld1,0) + Nz(fld2, 0)

The "=" tells Access that this is not a bound control.  The calculation will be updated if either fld1 or fld2 is changed.  Other solutions involve code.
Ok..I have a query ....but it will not allow me to update or data input into the empty fields.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So Pat...if I use    =Nz(fld1,0) + Nz(fld2, 0)  then it shows ...let's say fld1 is 74 and fld2 is 1...it shows 741 instead of 75
Then your table may have a problem.
"74" + "1" results in 741
74 + 1 results in 75.

Are you storing numbers as text by accident, or on purpose?
=CLng(Nz(fld1,0)) + CLng(Nz(fld2, 0))
can bandage that over -- but if you aren't storing numbers as text for a reason, then you should fix the table and use Pat's formula
As Nick suggested, the fields are defined as text which is why they concatenated rather than summed.  CLng() will convert them to Long Integers but that may or may not be the correct data type.  What data type are you expecting?
Ok..I have a query ....but it will not allow me to update or data input into the empty fields.
If those "empty fields" are your calculated fields, then you won't be able to update them.
No not calculated fields...I may have found the problem.  Is it okay to import a excel sheet and use that as a table???
Is it okay to import a excel sheet and use that as a table???
Import it as a new table, and it becomes and Access table and all is well
Link to it, so it remains an Excel sheet and then there are problems.

MS lost a patent case to a Guatemalan gentleman.
They have not purchased or leased his patents
Instead, they broke Access's ability to update linked Excel sheets to not violate his patent.
Data on a linked Excel sheet is read-only in Access
I made a table using a excel file.  I tried running that table with another table for a query..query is fine.  But when I make the form the blank fields..I can not enter in data.
You downloaded and look at the sample I posted here, right?

It had a table, form and query that shows how it all works.
Post a sample mdb file of your own if you can and wish.
I clicked on it...but can't access it...  Here you go
Database10.accdb
Ah,

EE has a bug at the moment.
for .accdb files you must right-click and SaveAs | All files and then give it the .accdb ending.
I'll have a look.
Do you want me to send it again
Ok,

Here is your file returned.
I have altered table Final_table
I have altered Query1
I have altered form Final_table.

I have created the 4 calculated fields/controls that I think you wanted
I have put them all on the form and arranged them
Calculated fields generally are not stored in the table.  I have removed them.
Query1 had no join.  I added it
Query1 does the calculating, and not the form

As noted above, for .accdb, right-click and SaveAs | All files | database10 v1.accdb
Database10-V1.accdb
Thank you for helping....but for some reason when I right click it does not give me an option to do a SaveAs
With IE 11, it is certainly an option.
Here it is on a OneDrive Link
.but for some reason when I right click it does not give me an option to do a SaveAs
If you're trying to download the file Nick posted, then you may just try clicking on it directly. I can do that, and it downloads fine on my machine.
In IE 11, accdb files try to open as html on a left-click.
Have since July.  Bug report filed, but the issue is not fixed.  Reported in the Glitches group too
Right-click | SaveAs | All files | name it *.accdb works.

But not a left-click
Ahhh ... I'm using Chrome and FireFox. Those browsers behave differently, it would seem
Yup,
Chrome, it works ok for.
Although boag200 runs Chrome without Quicktime and he couldn't run this attachment.
IE 11 without Quicktime would.
mapV3.mdb
I can download that one on my machine, using Chrome. Not sure if QT is installed or not.
Boag2000 could download it.
When he opened it without IE as the default browser it threw all sorts of errors.
It's got a WebBrowser control that displays Google Static maps with pins
Thanks..