PDA

View Full Version : Solved: display 100% maximum



av8tordude
01-09-2011, 01:20 PM
Dim v As String
v = Replace(Me.MPct, "%", "")
Me.MPct = Val(v) & "%"


I have this code that allows the user to enter percent number. I would like to prevent the user from enter anything greater than 100%.

i.e. if the user types 150% and exits from the textbox, display the amount as 100%. if the user enters 50% and exits from the textbox, then it displays 50%.

thank you for your help

Artik
01-09-2011, 02:08 PM
Like this:
Dim v As String

v = Replace(Me.MPct, "%", "")

If Val(v) > 100 Then v = 100
If Val(v) <= 0 Then v = 0

Me.MPct = v & "%"


Artik

av8tordude
01-09-2011, 02:42 PM
Works Great...Thank you :friends: