Solved

10 01 11 00__Numbers are Driving Me Crazy

Posted on 2000-05-11
6
152 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

803 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