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.

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.

Cheers,
Colin

On 2 June 2011 12:07, Marshland Engineering <marshl...@marshland.co.nz>wrote:

>  Thanks for the reply.
>
> >Write a procedure for the validation routine in the DataModule. Then
> >call it from the OnKeyPress event in each form.
>
> 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.
>
> 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.
>
> Thanks Wallace.
>
>
>
>
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi@delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
> unsubscribe
>
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Reply via email to