A possible way to validate fields on a field-by-field basis is to attach your validation on the OnDataChange event on the TDataSource component that is connected to the dataset. This event is triggered when you are scrolling to a new record or after you modify a field's value. The event takes in two parameters, the Sender and the affected Field. If you are scrolling records, the Field parameter is nil. If you are modifying a field, then the Field parameter is set to that TField instance. You basically need to have a set of if statements or a case statement to identify the field and then apply the validation to it.<div>
<br></div><div>I think this still works even if you don't hook up any db-aware components to this datasource. I think you can use separate datasource components on each of your forms and just add the validation rules to the datasource that sits on your datamodule. I'm guessing but you can give it a try and see if it works.</div>
<div><br></div><div>Cheers,</div><div>Colin<br><br><div class="gmail_quote">On 2 June 2011 12:07, Marshland Engineering <span dir="ltr"><<a href="mailto:marshland@marshland.co.nz">marshland@marshland.co.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff">
<div><font size="2" face="Arial">Thanks for the reply. </font></div><div class="im">
<div><font size="2" face="Arial"></font> </div>
<div>>Write a procedure for the validation routine in the DataModule.
Then<br>>call it from the OnKeyPress event in each form.</div>
<div><font size="2" face="Arial"></font><font size="2" face="Arial"></font> </div>
</div><div><font size="2" face="Arial">I have about 20 forms and 10 -20 entry points
on each form, so the OnKeyEvent looks like the long way round. The database
is only 20 fields long but each form shows a particular set of graphic for
the action so the user enters the data in the correct
fields. </font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">What I would like is to attach the validation to
the data field in the DM. That way I can also specify a range for the entry
which will be common to all forms.</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">Thanks Wallace.</font></div>
<div><font size="2" face="Arial"></font> </div>
<div> </div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial"> </font></div>
<div><br></div></div>
<br>_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe<br></blockquote></div><br></div>