V
Volker Neurath
Hi all,
i\'m not sure whether i\'m right here with my problem or not, but i try.
Situation:
I have a table with just one field \"myfield\" date-type is \"LONG\"
I also have a form with just one textbox. The form ist bound to the
table an the text box is bound to that one table-field.
There are no validation-rules defined within the field-definiton in the
table or the definiton of the form-control.
Now i try to handle user -input-errors. Because the table-field
only can take numbers i want to check the user\'s input if it is numeric
-
if it\'s not, the user should get a message.
The user should also get a message if he tries to leave the field
without typing in anything, i.e. leaving the field empty.
Problem:
i cannot figure out, how to do this.
Using the Form_Error Event i can check for runtime-error 2113 of
course - but i\'m not able to chekt if this error was fired because
of leaving the field empty or because the user tried to type in
non-numeric values.
This is my procedure in Form_Error:
------------------
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim ctl As Control
Set ctl = Screen.ActiveControl
If DataErr = 2113 Then
If IsNull(Me!Text0) then
MsgBox \"field must have a value!\"
ELSE
If Not (IsNumeric(Me!Text0)) Then
MsgBox \"Only numerical input allowed in \" & ctl.Name
Response = acDataErrContinue
Else
MsgBox \"Incorrect input in field \" & ctl.name
Response = acDataErrContinue
End If
End If
end if
End Sub
but: it doesn\'t work.It will allways run into the last \"ELSE\".
I also tried changing the table-field into a text-field and placed the
above code into the control\'s \"BeforeUpdate\"-Event (without the Err
2113-check of course)
-- no change in behaviour.
What am i doing wrong or better:
how can i do a working validation of user-input?
The above is \"only\" testing vor the validation of my actual project;
there i have a small database with
8 fields that have to be tested on many conditions such as:
- left empty?
- numeric?
- numeric and > 0?
- numeric, >0 and integer? (It\'s simply not possible to sell 0.5
printers )
- date?
- is the value (date or quotationnumber) > (or <) than the date (or
quotationnumber)
in another field on the same form?
The Access-verion is Access 2003
Volker
i\'m not sure whether i\'m right here with my problem or not, but i try.
Situation:
I have a table with just one field \"myfield\" date-type is \"LONG\"
I also have a form with just one textbox. The form ist bound to the
table an the text box is bound to that one table-field.
There are no validation-rules defined within the field-definiton in the
table or the definiton of the form-control.
Now i try to handle user -input-errors. Because the table-field
only can take numbers i want to check the user\'s input if it is numeric
-
if it\'s not, the user should get a message.
The user should also get a message if he tries to leave the field
without typing in anything, i.e. leaving the field empty.
Problem:
i cannot figure out, how to do this.
Using the Form_Error Event i can check for runtime-error 2113 of
course - but i\'m not able to chekt if this error was fired because
of leaving the field empty or because the user tried to type in
non-numeric values.
This is my procedure in Form_Error:
------------------
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim ctl As Control
Set ctl = Screen.ActiveControl
If DataErr = 2113 Then
If IsNull(Me!Text0) then
MsgBox \"field must have a value!\"
ELSE
If Not (IsNumeric(Me!Text0)) Then
MsgBox \"Only numerical input allowed in \" & ctl.Name
Response = acDataErrContinue
Else
MsgBox \"Incorrect input in field \" & ctl.name
Response = acDataErrContinue
End If
End If
end if
End Sub
but: it doesn\'t work.It will allways run into the last \"ELSE\".
I also tried changing the table-field into a text-field and placed the
above code into the control\'s \"BeforeUpdate\"-Event (without the Err
2113-check of course)
-- no change in behaviour.
What am i doing wrong or better:
how can i do a working validation of user-input?
The above is \"only\" testing vor the validation of my actual project;
there i have a small database with
8 fields that have to be tested on many conditions such as:
- left empty?
- numeric?
- numeric and > 0?
- numeric, >0 and integer? (It\'s simply not possible to sell 0.5
printers )
- date?
- is the value (date or quotationnumber) > (or <) than the date (or
quotationnumber)
in another field on the same form?
The Access-verion is Access 2003
Volker