By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,220 Members | 978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,220 IT Pros & Developers. It's quick & easy.

Evaluate UNBOUND textbox using custom function.

P: n/a
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 ???

May 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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 ***
May 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.