Solved

10 01 11 00__Numbers are Driving Me Crazy

Posted on 2000-05-11
6
150 Views
Last Modified: 2010-05-02
Hi,
I only have 20 points, if you can help me 15 of them are yours.

I declared c_Loan as currency in my VB program, the corresponding field in the access db is currency data type. Yet when I save, it does not save the decimals. 222.65 saves as 222. What am I doing wrong.

Do I have to format text boxes to show the decimals?

Any help would be appreciated. Have a good day programming. Thank you.

diek
0
Comment
Question by:diek_nf
6 Comments
 
LVL 2

Accepted Solution

by:
BobbyOwens earned 15 total points
ID: 2799873
Makre sure your field in the database is set to 2dp, or to Auto. (Check this by opening the table in design mode, selecting the field and checking the "Decimal Places" setting)

Also ensure that when the value is shown in the text box, it is done with comething like:

Format(value,"#.00#")

Lastly, check the value doesn't get read into a long or integer accidentally in VB Code
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2799876
Let's see you save/Load code please.

Normally what you're doing sounds like it should work.

Yes, the text boxes don't automatically know how many decimals to show.

The text box's .Text property is a string. If you're doing something like:

RS.Edit
RS!CurrencyField = Text1.Text
RS.Update

This can be the cause of the problem.

M
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 2800060
Hi

I have had problems with Currency Type before and I dont use them

I use Single instead.

From an accuracy point of view currency is theoretically more accurate.

You would have to be using very large amounts of money for it make any difference.

Try using a single instead.

I work with fianacials and cash flow for companies with $1 billion and No one ever complained about any very small rounding errors.

Good Luck

Voodooman!
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 18

Expert Comment

by:deighton
ID: 2800110
>>>Do I have to format text boxes to show the decimals?

Yes.  Or if you enter a value with no decimals e.g. 1234 you have to decide yourself in code if this will be become $1234.00 or $12.34

Is this what is going on?

if text1 was 1234

then

dim x as Currency

x = x = CCur(Text1) / 100

0
 
LVL 18

Expert Comment

by:deighton
ID: 2800111
oops!!

x = CCur(Text1) / 100
0
 

Author Comment

by:diek_nf
ID: 2800174
Bobby,
After playing the field in the db was farged up. The format thing, I took your advice and
'====== FORMAT CURRENCY
        Dim cur_temp_format As Currency

        cur_temp_format = rs_BBILF!Balance
        txtBalance.Text = Format(cur_temp_format, "$##0.00")
        cur_temp_format = 0
'===============================================================================
 If there is a less clutsy way someone please let me know.

Voodoo,
I am going to play with the single.

Thank you, I can always count on everyone to help.

If I can figure out why my ttolbar refuses to stay customized I will truly be a happy camper. If I don't figure it out soon I'll have to post it.

Have a great day programming.

diek
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now