By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,489 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,489 IT Pros & Developers. It's quick & easy.

Decimal places lost on access 2000 form!!

ollyb303
P: 74
Hi,

My colleague has a db with a form linked to a table. On the form is (among many other things) a checkbox and textbox. When the checkbox is checked, the value in the textbox should be 37.5, and when unchecked it should be 0.

I wrote this VBA for him:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CheckBox1_AfterUpdate()
  2. If CheckBox1 = -1 Then
  3. TextBox1.SetFocus
  4. TextBox1 = 37.5
  5. Else
  6. TextBox1.SetFocus
  7. TextBox1 = 0
  8. End If
  9. End Sub
Ok it works, sort of - The data type for the field is Long Integer/General Number/2 decimal Places. When the box is checked, the value in the textbox reads 38. I have tried other data types (decimal gave me a value of 37) and formats (fixed gave me 38.00).
What's going on? Have I missed something fundamental?

Any help gratefully received.

Olly
Jan 22 '08 #1
Share this Question
Share on Google+
2 Replies


jaxjagfan
Expert 100+
P: 254
Hi,

My colleague has a db with a form linked to a table. On the form is (among many other things) a checkbox and textbox. When the checkbox is checked, the value in the textbox should be 37.5, and when unchecked it should be 0.

I wrote this VBA for him:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CheckBox1_AfterUpdate()
  2. If CheckBox1 = -1 Then
  3. TextBox1.SetFocus
  4. TextBox1 = 37.5
  5. Else
  6. TextBox1.SetFocus
  7. TextBox1 = 0
  8. End If
  9. End Sub
Ok it works, sort of - The data type for the field is Long Integer/General Number/2 decimal Places. When the box is checked, the value in the textbox reads 38. I have tried other data types (decimal gave me a value of 37) and formats (fixed gave me 38.00).
What's going on? Have I missed something fundamental?

Any help gratefully received.

Olly
What is the format of Textbox1? Your data maybe correct but the control you use to display it may be the issue. Make sure Textbox1 format is Fixed with 2 decimal places. When you set the value to 0 it will display 0.00 if set right.
Jan 22 '08 #2

ollyb303
P: 74
thankyou that sorts it out :)
Jan 22 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.