Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate event and making it generic

Status
Not open for further replies.

Marlin

Programmer
Jan 29, 1999
3
GB
I've been trying to create a generic validation routine in the click event of a save button <br>
for a form containing data. The validation for every control is held in the validate event of<br>
each control (this is a generic function also in each control) <br>
<br>
What I can't understand is how do you call the validate event for every control in your<br>
code. The following below is nearly right except for the line<br>
<br>
Call lc_Control_Validate(False)<br>
<br>
it doesn't see the validate event with this <br>
<br>
If I use something like <br>
<br>
Call txt_WeightValue_Validate(False)<br>
<br>
This will work because it sees the control.<br>
<br>
<br>
Is there something about using a local holder for the control which makes it not see<br>
the events. If so then you will not be able to cycle through each control and initiate an<br>
event???<br>
<br>
<br>
dim lc_control as control <br>
<br>
'validate every control again seeing they may not have entered all controls<br>
'any with validation will be shown<br>
For Each lc_Control In Me.Controls<br>
On Error Resume Next<br>
<br>
Call lc_Control.Validate(True)<br>
Next<br>
On Error GoTo 0<br>
<br>
<br>
Thanks<br>
<br>
Marlin
 
To me, the way you are trying to do that logically will not work.&nbsp;&nbsp;A Sub or Function is defined by its name and not by the object it relates.&nbsp;&nbsp;An event sub is treated just like any other Sub, but an object calls it.&nbsp;&nbsp;<br><br>If you’re really interested in a general Validate function I would suggest sub classing. Just sub class the form and grab the Getfocus messages that are supposed to go to the controls. <br><br>I'm working on idea like that right now. I want to stop non-numbers from being pasted into textboxes.<br><br> <p>Clayton T. Paige<br><a href=mailto:cpaige@home.com>cpaige@home.com</a><br><a href= Snail</a><br>Clayton T. Paige<br>
Programmer Extraordinaire <br>
========================================================<br>
"Who General Failure? and Why is he reading my disk driver?
 
Marlin,<br><br>I just made a post in this forum in the thread &quot;How best to trap Exit from Controls? ...&quot;.&nbsp;&nbsp;It may address your issue. <p>John Kisner<br><a href=mailto:jlkisner@jlkisner.com>jlkisner@jlkisner.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top