473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Evaluate UNBOUND textbox using custom function.

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
1 2533
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jaYPee | last post by:
I have an unbound textbox in my report that is bound from the textbox in my Dialog Form using a controlsource using Access 97. However after I ported my database to SQL Server 2000 and use Access...
4
by: BerkshireGuy | last post by:
Hello, I have a query that references abn unbound textbox on a form to get the criteria. The unbound textbox can read 'Brian' or 'Dave'. Or just 'Brian'. However, I think the query is seeing...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
0
by: jason | last post by:
Hello everyone. I am trying to write some custom command events into a DataGrid. The command that is currently giving me trouble is an "Add" custom command in the footer of a template column. ...
1
by: z f | last post by:
Hi. How can I make a custom control in VB.NET that is inheriting from TextBox and also implements/inherits the IPostBackDataHandler? the problem is that in VB.NET I can't inherit from more that...
0
by: colleen1980 | last post by:
Hi: There are two textboxs in my main form. One is bound and another is unbound. There is no entry in the unbound textbox as values come into automatically after entering some information in the...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
3
by: Richard | last post by:
How is the result of query placed in a unbound textbox ? Suppose CriteriaLookups has columns TableName, KeyColumn, KeyValue, DataColumn Foo,x,11,xhat Bar,z,3,xyzzy And
1
by: dpark29 | last post by:
Access 2000 - If a textbox control is bound to a hyperlink field in an Access database table, the textbox appears formatted as hyperlink and when the user right-clicks the field, the Hyperlink option...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.