How to add currency and round 2 decemial place in a button (1 Viewer)

Nick.NZ

New member
Local time
Tomorrow, 01:54
Joined
Nov 14, 2021
Messages
15
Hi guys,

I've got a Save button that once clicked displays the Order total. I'm just not sure how to add the currency (dollars), and round to two decimal places. If it was a text box there is an option in the access interface, since it's a button i presume it needs to go into the code.

In the on click event macro I've simple got:

=[Test4 subform1].[Form]![Text18]

Text18 being the text box in the sub form the order total is calculated to.

See screenshots below if need be.

Thanks,
Nick
 

Attachments

  • access1.JPG
    access1.JPG
    52.6 KB · Views: 244
  • access2.JPG
    access2.JPG
    20.3 KB · Views: 237

Nick.NZ

New member
Local time
Tomorrow, 01:54
Joined
Nov 14, 2021
Messages
15
Put this in the Format Property of the textbox.

$#,##0.00
1637828885235.png
1637828913133.png


Hasn't worked unfortunately.

The same goes if i try and change the format with the drop down menu manually.

This only works when the event is coming from another text box. But because it's coming from a button with a macro it doesn't seem to change it.
 

Nick.NZ

New member
Local time
Tomorrow, 01:54
Joined
Nov 14, 2021
Messages
15
Is there a way to embed the code into
=[Test4 subform1].[Form]![Text18] ?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 23:54
Joined
Jan 20, 2009
Messages
12,849
On a bound form, a textbox in the header or footer can Sum a field in the recordset with:
=Sum(fieldname)

I don't know why the Format property isn't working. I don't have Access at home to test it.

Maybe it needs the $ escaped?
\$#,##0.00
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:54
Joined
Feb 19, 2002
Messages
42,981
Saving the record, saves the values entered. I'm not sure what your problem is. You only end up with more than two decimal places if you are doing calculations unless you actually enter more than two in the price field.

Formatting the data is NOT the same as saving a rounded value. In order to not have discrepancies, you would need to round when you saved the item records. Then the order just sums the rounded values. If you round at the end, some smart user will add up the details and find that you are a couple of pennies off every once in a while.
 

Users who are viewing this thread

Top Bottom