Solved

10 01 11 00__Numbers are Driving Me Crazy

Posted on 2000-05-11
6
151 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now