sum two field

D

David

Hello! Everybody

I create a simply table called table1. Three columns called col1, col2, col3
How do I sum column1 and column2 to column3 in the "default value" of the
table design view? Put expression like =[col1]+[col2] ??? but when save it
says db engine does not recognize the field col1 in a validation expression
or default value in the table 'table1' Thanks for the help.
 
D

Duane Hookom

You can't reference other fields in the default value in table design. You
could do this in a form. However, if col3 is always col1+col2 then I would
not store their sum in another field.
 
D

daivd

Can I sum other field put in col3 in the table design(not in default value)?
So, I can query the same table see col1, col2, col3.

Duane Hookom said:
You can't reference other fields in the default value in table design. You
could do this in a form. However, if col3 is always col1+col2 then I would
not store their sum in another field.

--
Duane Hookom
MS Access MVP


David said:
Hello! Everybody

I create a simply table called table1. Three columns called col1, col2, col3
How do I sum column1 and column2 to column3 in the "default value" of the
table design view? Put expression like =[col1]+[col2] ??? but when save it
says db engine does not recognize the field col1 in a validation expression
or default value in the table 'table1' Thanks for the help.
 
D

Duane Hookom

No, you can't create a calculated field in a table. Did you understand my
previous comments about not storing a calculated value?

--
Duane Hookom
MS Access MVP


daivd said:
Can I sum other field put in col3 in the table design(not in default value)?
So, I can query the same table see col1, col2, col3.

Duane Hookom said:
You can't reference other fields in the default value in table design. You
could do this in a form. However, if col3 is always col1+col2 then I would
not store their sum in another field.

--
Duane Hookom
MS Access MVP


David said:
Hello! Everybody

I create a simply table called table1. Three columns called col1,
col2,
col3
How do I sum column1 and column2 to column3 in the "default value" of the
table design view? Put expression like =[col1]+[col2] ??? but when
save
it
says db engine does not recognize the field col1 in a validation expression
or default value in the table 'table1' Thanks for the help.
 
D

david

Thanks for the reply. But the form query from table. There is no way to store
the result to the table?

Duane Hookom said:
No, you can't create a calculated field in a table. Did you understand my
previous comments about not storing a calculated value?

--
Duane Hookom
MS Access MVP


daivd said:
Can I sum other field put in col3 in the table design(not in default value)?
So, I can query the same table see col1, col2, col3.

Duane Hookom said:
You can't reference other fields in the default value in table design. You
could do this in a form. However, if col3 is always col1+col2 then I would
not store their sum in another field.

--
Duane Hookom
MS Access MVP


Hello! Everybody

I create a simply table called table1. Three columns called col1, col2,
col3
How do I sum column1 and column2 to column3 in the "default value" of the
table design view? Put expression like =[col1]+[col2] ??? but when save
it
says db engine does not recognize the field col1 in a validation
expression
or default value in the table 'table1' Thanks for the help.
 
D

Duane Hookom

Sure, you can use the after update event of one or both of the first two
text boxes to add the values and set the value of the third text box.

--
Duane Hookom
MS Access MVP


david said:
Thanks for the reply. But the form query from table. There is no way to store
the result to the table?

Duane Hookom said:
No, you can't create a calculated field in a table. Did you understand my
previous comments about not storing a calculated value?

--
Duane Hookom
MS Access MVP


daivd said:
Can I sum other field put in col3 in the table design(not in default value)?
So, I can query the same table see col1, col2, col3.

:

You can't reference other fields in the default value in table
design.
You
could do this in a form. However, if col3 is always col1+col2 then I would
not store their sum in another field.

--
Duane Hookom
MS Access MVP


Hello! Everybody

I create a simply table called table1. Three columns called col1, col2,
col3
How do I sum column1 and column2 to column3 in the "default value"
of
the
table design view? Put expression like =[col1]+[col2] ??? but
when
save
it
says db engine does not recognize the field col1 in a validation
expression
or default value in the table 'table1' Thanks for the help.
 
R

Reggie

David, What Duane is trying to tell you is that if col3 is always = col1 + col2 then there is no
need to store that value in your table. When you want to see the results use a calculated control
to display the value in your reports/queries/forms like so.
Query: Design a new query based on the table in question. Drag col1 and col2 down to the query
grid. In the 3rd empty column type in =[col1]+[col2] in the Field row.

Form/Report: Place an unbound textbox on your form/report. Double-click it to open the properties
window. Type in =[col1]+[col2] as the Control Source.

This way you don't waste space and should the values of col1 or col2 change you will always display
the correct result without having to update col3.

Hope this helps!

--
Reggie

----------
david said:
Thanks for the reply. But the form query from table. There is no way to store
the result to the table?

Duane Hookom said:
No, you can't create a calculated field in a table. Did you understand my
previous comments about not storing a calculated value?

--
Duane Hookom
MS Access MVP


daivd said:
Can I sum other field put in col3 in the table design(not in default value)?
So, I can query the same table see col1, col2, col3.

:

You can't reference other fields in the default value in table design. You
could do this in a form. However, if col3 is always col1+col2 then I would
not store their sum in another field.

--
Duane Hookom
MS Access MVP


Hello! Everybody

I create a simply table called table1. Three columns called col1, col2,
col3
How do I sum column1 and column2 to column3 in the "default value" of the
table design view? Put expression like =[col1]+[col2] ??? but when save
it
says db engine does not recognize the field col1 in a validation
expression
or default value in the table 'table1' Thanks for the help.
 
D

david

Thanks alot. How about if I need to display sum of col1 and col2 from under
table to an asp webpage?

Reggie said:
David, What Duane is trying to tell you is that if col3 is always = col1 + col2 then there is no
need to store that value in your table. When you want to see the results use a calculated control
to display the value in your reports/queries/forms like so.
Query: Design a new query based on the table in question. Drag col1 and col2 down to the query
grid. In the 3rd empty column type in =[col1]+[col2] in the Field row.

Form/Report: Place an unbound textbox on your form/report. Double-click it to open the properties
window. Type in =[col1]+[col2] as the Control Source.

This way you don't waste space and should the values of col1 or col2 change you will always display
the correct result without having to update col3.

Hope this helps!

--
Reggie

----------
david said:
Thanks for the reply. But the form query from table. There is no way to store
the result to the table?

Duane Hookom said:
No, you can't create a calculated field in a table. Did you understand my
previous comments about not storing a calculated value?

--
Duane Hookom
MS Access MVP


Can I sum other field put in col3 in the table design(not in default
value)?
So, I can query the same table see col1, col2, col3.

:

You can't reference other fields in the default value in table design.
You
could do this in a form. However, if col3 is always col1+col2 then I
would
not store their sum in another field.

--
Duane Hookom
MS Access MVP


Hello! Everybody

I create a simply table called table1. Three columns called col1,
col2,
col3
How do I sum column1 and column2 to column3 in the "default value" of
the
table design view? Put expression like =[col1]+[col2] ??? but when
save
it
says db engine does not recognize the field col1 in a validation
expression
or default value in the table 'table1' Thanks for the help.
 
R

Reggie

David, Not real familiar with ASP, but I would think that instead of connecting you datasource to
the table you should be able to use the query you designed with the calculated control, as the
datasource.

--
Reggie

----------
david said:
Thanks alot. How about if I need to display sum of col1 and col2 from under
table to an asp webpage?

Reggie said:
David, What Duane is trying to tell you is that if col3 is always = col1 + col2 then there is no
need to store that value in your table. When you want to see the results use a calculated
control
to display the value in your reports/queries/forms like so.
Query: Design a new query based on the table in question. Drag col1 and col2 down to the query
grid. In the 3rd empty column type in =[col1]+[col2] in the Field row.

Form/Report: Place an unbound textbox on your form/report. Double-click it to open the
properties
window. Type in =[col1]+[col2] as the Control Source.

This way you don't waste space and should the values of col1 or col2 change you will always
display
the correct result without having to update col3.

Hope this helps!

--
Reggie

----------
david said:
Thanks for the reply. But the form query from table. There is no way to store
the result to the table?

:

No, you can't create a calculated field in a table. Did you understand my
previous comments about not storing a calculated value?

--
Duane Hookom
MS Access MVP


Can I sum other field put in col3 in the table design(not in default
value)?
So, I can query the same table see col1, col2, col3.

:

You can't reference other fields in the default value in table design.
You
could do this in a form. However, if col3 is always col1+col2 then I
would
not store their sum in another field.

--
Duane Hookom
MS Access MVP


Hello! Everybody

I create a simply table called table1. Three columns called col1,
col2,
col3
How do I sum column1 and column2 to column3 in the "default value" of
the
table design view? Put expression like =[col1]+[col2] ??? but when
save
it
says db engine does not recognize the field col1 in a validation
expression
or default value in the table 'table1' Thanks for the help.
 
S

StCyrM

Good morning

You should not be saving the results of Col1 and Col2 into your table since the
result can be calculated at any time and viewed.

Col3 should be an unbound text box control whose control source should be set
as follows:

=NZ(Col1,0) + NZ(Col2,0)

Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.
 

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