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

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.
getekeAsked:
Who is Participating?
 
puppydogbuddyConnect With a Mentor Commented:
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
 
getekeAuthor Commented:
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
 
Bob LearnedCommented:
I have not used the TextBox in that manner to get a currency editor.  Have you tried the MaskedTextBox for that?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
getekeAuthor Commented:
@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
 
puppydogbuddyCommented:
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
 
Bob LearnedCommented:
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
 
getekeAuthor Commented:
@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
 
Bob LearnedCommented:
What is different between your application, and the "new test program"?
0
 
getekeAuthor Commented:
@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
 
getekeAuthor Commented:
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
 
getekeAuthor Commented:
@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
 
puppydogbuddyCommented:
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
 
getekeConnect With a Mentor Author Commented:
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
 
getekeAuthor Commented:
@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
 
getekeAuthor Commented:
puppydogbuddy had lead me to recreate the dataset, so the points will go to him.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.