[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB 2010 - Currency Textbox will not accept pennies (anything after decimal)

Posted on 2011-04-27
15
Medium Priority
?
934 Views
Last Modified: 2012-06-21
I have several textboxes with an Advanced Data Binding of "Currency" with "Null value = 0.00" and "Decimal Places = 2".  The textboxes perform financial calculations, but when you put a penny amount (regardless of dollar amount), the textbox will lock up and not allow you to exit the program or click on any other textbox.

Why is this happening? Is there a better way to have a currency textbox?

Thanks in advance.
0
Comment
Question by:geteke
  • 9
  • 3
  • 3
15 Comments
 

Author Comment

by:geteke
ID: 35477259
I have found something that may or may not be helpful.

If I go into the 'Advanced Data Binding' property of any of the textboxes, then I change the 'Data Source Update Mode' to "Never", I can then click out of the textbox.  It does not allow me to save, however.

Is this connected to the problem?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35482795
I have not used the TextBox in that manner to get a currency editor.  Have you tried the MaskedTextBox for that?
0
 

Author Comment

by:geteke
ID: 35483518
@TheLearnedOne        I have tried to use a MaskedTextBox, but the numbers do not format correctly.  

In the Access Database, the fields are "Currency" with "Decimal Places: 2".  The DataSet has them as "System.Double."  Are these correct for financial fields?

Should the data types be "string" or "text", in which I can set the formatting to my own liking and it may solve the cents problem?  I do not wish to do this, however, if there exists a better way to solve this problem.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 35483915
If you are using an Access database, Formatting on the form or query will override the table format for display purposes on the form or query.  So verify that the format setting for the textbox on your form is Currency to 2 decimal places.  
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35484029
String or text values cannot be formatted, they would need to be converted to numeric types before they could be formatted, so you have what you need.  

What do you mean by "but the numbers do not format correctly"?
0
 

Author Comment

by:geteke
ID: 35484213
@TheLearnedOne I meant that the numbers in the field would move to the left, leaving open space on the right.

Now the program rounds the money amount that I give it (say $1034.78) up to the nearest dollar ($1035).  It does save, but only saves the whole number and I no longer get concurrency errors.

Why is this happening?  Is there a way to set the rounding ability?
(P.S., I created another small program with an Access Database, which accepts money amounts with cents just fine.  I do not wish to redo my entire program if something very small is causing my program to not accept cents, but the 'new test program' can.)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35484236
What is different between your application, and the "new test program"?
0
 

Author Comment

by:geteke
ID: 35484300
@TheLearnedOne    My program (let's call it REAL) has a generic binding navigator and the Access Database has some currency fields.  The TEST program has two fields, one of which is a currency field identical to the ones found in REAL.

What of the rounding that is occuring in the values?  Is it happening when it is saved into the Access Database or before it is saved?
0
 

Author Comment

by:geteke
ID: 35484487
I have found that the program will "accept" money amounts with cents, and will save, but save the whole number (no cents). When I set the value in the Access Database to a money amount with cents (say 53.89), I query the entry and then save, I get a concurrency error.  The program will allow you to input and save a correct value, but it will not take it from the Access Database.

What is going on?  Is there a way to alter this?
0
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 2000 total points
ID: 35485031
Did you look at my previous response?  Check the format and/or rounding properties set in your form/query for the textbox.  If the setting in your form/query is different than in your table, the form/query settings will override the settings in the table. ..change settings in the form/query to conform to table settings.
0
 

Author Comment

by:geteke
ID: 35485135
@puppydogbuddy How would one be able to check/edit the format?  There is no format set for the textboxes, and there is no format set for the queries.
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 35485390
To test, place the query in design view, right click the problem field, select properties to bring up property sheet, set format to Currency to conform to table format.
0
 

Assisted Solution

by:geteke
geteke earned 0 total points
ID: 35485425
I have found a solution.  I made a backup of the dataset file, and recreated the dataset with all its queries.  The problem has disappeared.  It seems that something in the dataset was causing this.  Is there a way to compare both datasets to see where the problem came from?
0
 

Author Comment

by:geteke
ID: 35485499
@puppydogbuddy    I should have been more specific.  The queries I'm running are from Visual Studio. I'm not using queries created in Access.  Sorry for the confusion.  You did lead me to the right answer, however.
0
 

Author Closing Comment

by:geteke
ID: 35510855
puppydogbuddy had lead me to recreate the dataset, so the points will go to him.  Thanks!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

873 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