Evaluate UNBOUND textbox using custom function.

Evaluate UNBOUND textbox using custom function.

am 09.05.2006 22:55:06 von ApexData

Hello

I have an UNBOUND textbox Text1 that I want to validate in code.
I want to lock the user into the field until Valid Data is entered.
I created the following Function:

Private Function Validate(MyControl As Control) As Boolean
If Len([Text1]) < 6 Then
MsgBox "Password too small"
' Etc..Etc.......
Validate = True
Else
Validate=False
End If
End Function

I tried each of the following INDIVIDUALLY and ran into problems:

Validation Rule =Validate([Text1])
'Keeps evaluating as True, despite the function running properly.

On Change =Validate([Text1])
'Evaluates character by character. Not good here.

Before Update =Validate([Text1])
'Evaluates fine, but allows the user to leave the field in error

AfterUpdate =Validate([Text1])
'Evaluates fine, but allows the user to leave the field in error

I want to validate at the control not the form level, and I want
to evaluate in a custom coded function as shown.

Any Advice ???

Re: Evaluate UNBOUND textbox using custom function.

am 10.05.2006 00:52:38 von Rich P

Use a dialog form to open it modally. You can trap for incorrect input
in the Close event of the form. If the input is incorrect - don't close
the form or close the app. The only way to close it would be to kill
the app.


DoCmd.OpenForm "passwordForm", , , , , acDialog

If passwordForm.IsOK() = False Then
DoCmd.Close acForm, Me.Name
GoTo Exit_Form_Open
End If

You can also create custom properties (Get, Set, Let) within the dialog
form to return the input. If the input is invalid, the shut things
down.


set this property in the passwordForm. When you close the passwordForm
you can now trap the input.

Public Property Get IsOk() As Boolean
IsOk = m_IsOk
End Property


Rich

*** Sent via Developersdex http://www.developersdex.com ***