Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a text to a field expecting a double

Status
Not open for further replies.

coughnut

Programmer
Dec 6, 2005
27
0
0
US
This question might sound dumb, but I am not sure how to make this possible. I have created a table using Vba, and some of the fields in the table I have specified to accept doubles, since I am expecting dollar amount here. I want to be able to add a dollar sign as well as the number to the table. Here is how I am creating my field:
Set fld = table.CreateField("Amount", dbDouble)
table.Fields.Append fld
in another funtion I am reading in a file that has the amount with no dollar sign next to it, so I want to add it. Here is what I have tried and it is not working:
rs.Fields("Total").Value = "$" & Round(total, 2)
can anyone be of any help, thank you in advance.
 


Hi,

The cash symbol is ONLY a DISPLAY FORMAT ATTRIBUTE. It is NOT part of the data value.

Skip,
[sub]
[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue][/sub]
 
Here is my question. It looks like you make a field named Amount:

Set fld = table.CreateField("Amount", dbDouble)

Then you are asking about putting a $ in a field named Total:

rs.Fields("Total").Value = "$" & Round(total, 2)

So which field is the problem?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Oh...and I agree with Skip on the proper way to use currency symbols...I just wanted clarification on the base question. Either way the answer will be that the amount should be stored as a double then simply DISPLAYED with a currency symbol.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Any reason for a double versus a currency data type? If you doing currency calculations usually the Currency data type can help avoid certain problems like floating point arithmetic.
 
Sorry I meant to type :
rs.Fields("Total").Value = "$" & Round(total, 2)
This gets the number put does not put in the dollar sign
 
See the above posts about not putting the dollar sign in the field.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 

Hey coughnut,

Do you read and understand the replys to your question?

Skip,
[sub]
[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top