Adding currency fields together

G

Guest

I am attempting to add two currency fields together in an Access 2003 Form by
inserting the following expression in the Control Source:
=[1_Price] + [2_Price] Extraordinarily it strings the values together like
$20$50.

To check the methodology I replaced the + sign with -, * and / and each of
these worked exactly as I would expect.

I have exhausted all help facilities.
 
G

Guest

Are [1_Price] and [2_Price] actual numeric fields from a table?
Are you applying a format in the report's record source?
Do the two fields appear left or right-aligned in the datasheet view of the
report's record source?
 
G

Guest

[1_Price] and [2_Price] are actual numeric fields from a table
Both these fields, and the Total field, are formatted as Currency
Both these fields, and the Total field, have Text Align set to General

Duane Hookom said:
Are [1_Price] and [2_Price] actual numeric fields from a table?
Are you applying a format in the report's record source?
Do the two fields appear left or right-aligned in the datasheet view of the
report's record source?
--
Duane Hookom
Microsoft Access MVP


gdas australia said:
I am attempting to add two currency fields together in an Access 2003 Form by
inserting the following expression in the Control Source:
=[1_Price] + [2_Price] Extraordinarily it strings the values together like
$20$50.

To check the methodology I replaced the + sign with -, * and / and each of
these worked exactly as I would expect.

I have exhausted all help facilities.
 
J

John Spencer

For some reason the fields are being treated as if they were text fields
and not number fields. Duane was attempting to determine if they were
being treated as text. When displayed text fields align to the left,
number fields align to the right.

Try
cCurrancy(1_Price) + CCurrency(2_Price)

As long as the fields consist of only numeric characters, this should work.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


gdas said:
[1_Price] and [2_Price] are actual numeric fields from a table
Both these fields, and the Total field, are formatted as Currency
Both these fields, and the Total field, have Text Align set to General

Duane Hookom said:
Are [1_Price] and [2_Price] actual numeric fields from a table?
Are you applying a format in the report's record source?
Do the two fields appear left or right-aligned in the datasheet view of the
report's record source?
--
Duane Hookom
Microsoft Access MVP


gdas australia said:
I am attempting to add two currency fields together in an Access 2003 Form by
inserting the following expression in the Control Source:
=[1_Price] + [2_Price] Extraordinarily it strings the values together like
$20$50.

To check the methodology I replaced the + sign with -, * and / and each of
these worked exactly as I would expect.

I have exhausted all help facilities.
 
G

Guest

Have tried this but received error message saying operand and / or syntax
incorrect.

I couldn't find any reference to cCurrency in the help files, so I tried
Currency on its own. Same error message!

Why does it work OK with minus, multiply and division?

John Spencer said:
For some reason the fields are being treated as if they were text fields
and not number fields. Duane was attempting to determine if they were
being treated as text. When displayed text fields align to the left,
number fields align to the right.

Try
cCurrancy(1_Price) + CCurrency(2_Price)

As long as the fields consist of only numeric characters, this should work.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


gdas said:
[1_Price] and [2_Price] are actual numeric fields from a table
Both these fields, and the Total field, are formatted as Currency
Both these fields, and the Total field, have Text Align set to General

Duane Hookom said:
Are [1_Price] and [2_Price] actual numeric fields from a table?
Are you applying a format in the report's record source?
Do the two fields appear left or right-aligned in the datasheet view of the
report's record source?
--
Duane Hookom
Microsoft Access MVP


:

I am attempting to add two currency fields together in an Access 2003 Form by
inserting the following expression in the Control Source:
=[1_Price] + [2_Price] Extraordinarily it strings the values together like
$20$50.

To check the methodology I replaced the + sign with -, * and / and each of
these worked exactly as I would expect.

I have exhausted all help facilities.
 
A

Allen Browne

It's CCur(), not cCurrancy()

Also, make sure the values are not null, i.e.:
CCur(Nz([1_Price], 0)) + CCur(Nz([2_Price], 0))

If that still fails, open your table in design view.
Change 1_Price to Currency instead of Text.
Same for 2_Price.

The reason the plus operator fails is that it is ambiguous, i.e. it can be
used for addition and for concatenation.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

gdas australia said:
Have tried this but received error message saying operand and / or syntax
incorrect.

I couldn't find any reference to cCurrency in the help files, so I tried
Currency on its own. Same error message!

Why does it work OK with minus, multiply and division?

John Spencer said:
For some reason the fields are being treated as if they were text fields
and not number fields. Duane was attempting to determine if they were
being treated as text. When displayed text fields align to the left,
number fields align to the right.

Try
cCurrancy(1_Price) + CCurrency(2_Price)

As long as the fields consist of only numeric characters, this should
work.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


gdas said:
[1_Price] and [2_Price] are actual numeric fields from a table
Both these fields, and the Total field, are formatted as Currency
Both these fields, and the Total field, have Text Align set to General

:

Are [1_Price] and [2_Price] actual numeric fields from a table?
Are you applying a format in the report's record source?
Do the two fields appear left or right-aligned in the datasheet view
of the
report's record source?
--
Duane Hookom
Microsoft Access MVP


:

I am attempting to add two currency fields together in an Access 2003
Form by
inserting the following expression in the Control Source:
=[1_Price] + [2_Price] Extraordinarily it strings the values
together like
$20$50.

To check the methodology I replaced the + sign with -, * and / and
each of
these worked exactly as I would expect.

I have exhausted all help facilities.
 
G

Guest

Many thanks Allen,

GREAT, works fine. I never realised that a + sign was ambiguous or in fact
that CCur existed. Say hello to Perth for me.

David (in Sydney)

Allen Browne said:
It's CCur(), not cCurrancy()

Also, make sure the values are not null, i.e.:
CCur(Nz([1_Price], 0)) + CCur(Nz([2_Price], 0))

If that still fails, open your table in design view.
Change 1_Price to Currency instead of Text.
Same for 2_Price.

The reason the plus operator fails is that it is ambiguous, i.e. it can be
used for addition and for concatenation.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

gdas australia said:
Have tried this but received error message saying operand and / or syntax
incorrect.

I couldn't find any reference to cCurrency in the help files, so I tried
Currency on its own. Same error message!

Why does it work OK with minus, multiply and division?

John Spencer said:
For some reason the fields are being treated as if they were text fields
and not number fields. Duane was attempting to determine if they were
being treated as text. When displayed text fields align to the left,
number fields align to the right.

Try
cCurrancy(1_Price) + CCurrency(2_Price)

As long as the fields consist of only numeric characters, this should
work.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


gdas australia wrote:
[1_Price] and [2_Price] are actual numeric fields from a table
Both these fields, and the Total field, are formatted as Currency
Both these fields, and the Total field, have Text Align set to General

:

Are [1_Price] and [2_Price] actual numeric fields from a table?
Are you applying a format in the report's record source?
Do the two fields appear left or right-aligned in the datasheet view
of the
report's record source?
--
Duane Hookom
Microsoft Access MVP


:

I am attempting to add two currency fields together in an Access 2003
Form by
inserting the following expression in the Control Source:
=[1_Price] + [2_Price] Extraordinarily it strings the values
together like
$20$50.

To check the methodology I replaced the + sign with -, * and / and
each of
these worked exactly as I would expect.

I have exhausted all help facilities.
 

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