Numeric Field control

sohailcdc

Registered User.
Local time
Today, 13:18
Joined
Sep 25, 2012
Messages
55
Hi there
Can anyone help me, how to control the numeric field range
e.g. number 00.01< and > 99.99
I am looking for some simply code under On Change() event

Apart from this, would be help full, how I can restrict the field should only take input number no character or special characters

Thanks in advance all
 
At the table level the field should be set as Data Type number.
The following properties for this field should be set:
Field Size: Single
Format: Fixed
Validation: Rule >=0.01 And <=99.99
 
Thanks Bob

I am trying to learn controls at form level (unbound form)
Specially event behaviours how to control field with event
e.g. at character field
Private sub on change()
if len(field name) > 10 then
Msgbox "Field characters can't be more than 10"
End if
End Sub

Same way, I want to control the numeric field, which mean can't be nil nor more than XXX number

Hope to hear you soon
 
What you want to do could be done by setting the appropriate properties of the text box in much the same way that it could be done at the table level. However, if you want to do it with code, try the following code in the Before Update event of the text box.
Code:
  If Not IsNumeric(Me.ActiveControl) Then
    Cancel = True
    MsgBox "Entry must be numeric"
  ElseIf Not Me.ActiveControl > 0 Or Not Me.ActiveControl <= 100 Then
    Cancel = True
    MsgBox "Enter number lager than 0 and not more than 100"
  End If
 
What abot this?

Code:
Private Sub Text1_AfterUpdate()
    If Me.Text1.Value <= 0 Or Me.Text1.Value >= 100 Then
        MsgBox "Can't be nil nor equal or greater than 100"
    End If
End Sub
 
Thank you Bob
I am just trying to play with Access during my free time at form level, which mean no table behind it
Anyways, thanks for your help
Be happy always
 

Users who are viewing this thread

Back
Top Bottom