AfterUpdate Event for TextBox

  • Thread starter Thread starter Curtis Stevens
  • Start date Start date
C

Curtis Stevens

I have this code for the afterupdate event on a text box that has data in it.

Me.Text732 = Replace(Abs(Val([Text732])), ".", "")

When I past this data 0000272400123456 into the text box, it gets rid of the
0000, becomes 272400123456

But if I past this kind of number 4223697600059898, it turns it into this
42236976000599E+15

If I take the coding away and past the 4223697600059898 number, it stays the
same and doesn't get changed to the +15.

Any suggestions or changes to code to fix this?

Thanks!

Curtis
 
if its a text field then it shouldnt be modifying any values that you enter
into it - check the field to make sure that its set up as a text field in the
table and on the form itself
 
Using the Val function turns the string into a number. Numbers do not have
leading zeros. You will need to treat the value in the text box as a string.
 
Curtis Stevens said:
I have this code for the afterupdate event on a text box that has data in
it.

Me.Text732 = Replace(Abs(Val([Text732])), ".", "")

When I past this data 0000272400123456 into the text box, it gets rid of
the
0000, becomes 272400123456

But if I past this kind of number 4223697600059898, it turns it into this
42236976000599E+15

If I take the coding away and past the 4223697600059898 number, it stays
the
same and doesn't get changed to the +15.

Any suggestions or changes to code to fix this?


It's weird to be doing string operations on a number. What are you actually
trying to accomplish? Also, is this text box bound or unbound, if bound
what is it bound to, and should it always contain a number?
 
Curtis said:
I have this code for the afterupdate event on a text box that has data in it.

Me.Text732 = Replace(Abs(Val([Text732])), ".", "")

When I past this data 0000272400123456 into the text box, it gets rid of the
0000, becomes 272400123456

But if I past this kind of number 4223697600059898, it turns it into this
42236976000599E+15

If I take the coding away and past the 4223697600059898 number, it stays the
same and doesn't get changed to the +15.


That string of digits is too long for the Val function to
convert to a number. Instead of trying to manipulate the
digits with numeric functions, you should think of it as a
text string.

It looks like all your line of code is doing is deleteing
any dots in the string of digits. In that case, there is no
reason to use Abs(Val(

OTOH, your code does nothing to prevent a user from entering
non numeric digits, which will also mess up the result of
using Val.

Maybe you have some other unexplained things going on, but I
am having trouble guessing at what objective that code is
attempting to achieve.
 
Back
Top