Subject | RE: [IBO] Using OnValidateField? |
---|---|
Author | Paul Hope |
Post date | 2008-07-15T20:21:59Z |
Hello Jason
Hope all is well with you.
My OnValidateField containes stuff like this
if (AField.FieldName='WHS')and(not ARow.ByName('WHS_DATE').IsNull) then
raise exception.Create('Warehouse cannot be changed when booked in');
in OnExit from the grid I tried this
if qContainers.NeedToPost then
try
qContainers.Post;
except
qContainers.Cancel;
end;
but it never executes because raising the exception in OnValidateField
ditches the rest of the process (including OnError).
I could do the flag thing but dont think it is any easier than calling
PostMessage from OnValidateField to a procedure which calls cancel.
If there isnt a neater way, maybe OnValdateField could have an
OnExceptionAction option with vfCancel as a possible value? (or something -
just a thought)
Regards
Paul
Hope all is well with you.
My OnValidateField containes stuff like this
if (AField.FieldName='WHS')and(not ARow.ByName('WHS_DATE').IsNull) then
raise exception.Create('Warehouse cannot be changed when booked in');
in OnExit from the grid I tried this
if qContainers.NeedToPost then
try
qContainers.Post;
except
qContainers.Cancel;
end;
but it never executes because raising the exception in OnValidateField
ditches the rest of the process (including OnError).
I could do the flag thing but dont think it is any easier than calling
PostMessage from OnValidateField to a procedure which calls cancel.
If there isnt a neater way, maybe OnValdateField could have an
OnExceptionAction option with vfCancel as a possible value? (or something -
just a thought)
Regards
Paul
> -----Original Message-----
> From: IBObjects@yahoogroups.com
> [mailto:IBObjects@yahoogroups.com] On Behalf Of Jason Wharton
> Sent: 15 July 2008 17:30
> To: IBObjects@yahoogroups.com
> Subject: Re: [IBO] Using OnValidateField?
>
> Paul,
>
> I'm not sure how you can work around this as I don't know the
> whole picture. What are you calling on OnValidateField? If
> you are calling Cancel there then this would be a problem.
> It's only job is to do nothing or raise an exception. The
> exception should be handled in the code where Post is called.
>
> If something comes up when OnValidateField is called that
> indicates the edits to the record should be cancelled then it
> should set a flag variable to indicate this. Then, you could
> put exception handling around your call to post to check and
> see if the indicator to cancel was flagged and if so then it
> would go ahead and call Cancel.
>
> Does this help?
>
> Jason
>
> --- In IBObjects@yahoogroups.com, "Paul Hope" <paulhope@...> wrote:
> >
> > I'm using OnValidateField for a TIB_Query connected to a
> TIB_Grid.
> > The grid has only 1 line of data.
> > I put in a bad value and click the OK button which calls 'if
> > query.needtopost then query.post'
> > The error is displayed and the value in the grid returns to its
> original
> > value.
> > Clicking OK again raises the error again even thought the grid is
> showing
> > the old (acceptable) value.
> > The only way to get out is to press Esc, which doesnt change
> anything
> > visually (including the indicator column), then click OK again.
> >
> > This is very confusing for the user.
> >
> > I could post a message in OnValidateField handler which calls
> query.cancel
> > but this seems somewhat cumbersome.
> >
> > Is there a better way of doing this?
> >
> > Regards
> > Paul
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
> ------------------------------------
>
> ______________________________________________________________
> _____________
> IB Objects - direct, complete, custom connectivity to
> Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> ______________________________________________________________
> _____________
> http://www.ibobjects.com - your IBO community resource for
> Tech Info papers,
> keyword-searchable FAQ, community code contributions and more
> ! Yahoo! Groups Links
>
>
>