469,963 Members | 1,974 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

Decimal places lost on access 2000 form!!

ollyb303
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
2 1666
jaxjagfan
254 Expert 100+
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
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.

Similar topics

1 post views Thread by Ellis | last post: by
2 posts views Thread by Hank | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.