Board index » delphi » Adjusting dbEdit contents before update

Adjusting dbEdit contents before update

I'm trying to apply some enhanced date conversion code to a dbEdit
component which is linked to a DateField.  My code allows dates like "feb 3
1997", "19970203" & "N/A"

Obviously, these formats can't be successfully inserted into a date field,
so I need to adjust them before Delphi attempts it.  How do I accomplish
that?  I don't seem to be able to find the right event to attach the code
to.

In the case of the N/A response, I'd be changing the data to 01/23/45 (a
date which I know I will never use, and which will therfore represent the
N/A response in the database).  So when Delphi wants to display the
contents of the database fields it needs to convert 01/23/45 to N/A before
doing so.  Again, which event do I latch onto for this.  

Any help will be much appreciated.
--
David Jennings
dav...@pacbell.net

 

Re:Adjusting dbEdit contents before update


Quote
David Jennings wrote:

> I'm trying to apply some enhanced date conversion code to a dbEdit
> component which is linked to a DateField.  My code allows dates like "feb 3
> 1997", "19970203" & "N/A"

> Obviously, these formats can't be successfully inserted into a date field,
> so I need to adjust them before Delphi attempts it.  How do I accomplish
> that?  I don't seem to be able to find the right event to attach the code
> to.

> In the case of the N/A response, I'd be changing the data to 01/23/45 (a
> date which I know I will never use, and which will therfore represent the
> N/A response in the database).  So when Delphi wants to display the
> contents of the database fields it needs to convert 01/23/45 to N/A before
> doing so.  Again, which event do I latch onto for this.

> Any help will be much appreciated.
> --
> David Jennings
> dav...@pacbell.net

Use the underlying database field events OnSetText and OnGetText. These
are called each time the Text property is accessed.

Menno Holscher

Re:Adjusting dbEdit contents before update


        Sounds like you need to write your own TDBEdit component.  This is not as
daunting a task as it may seem.  If you can spare a weekend, read the
Component Writer's Guide and walk through one or two of the examples.  It
will change you (Delphi, programming) life.
--
Rob Tanner B.E.,B.Sc.
Design Engineer
WestBau Technologies, Inc.

David Jennings <dav...@pacbell.net> wrote in article
<01bc3eef$c472e060$077baace@davjen>...

Quote
> I'm trying to apply some enhanced date conversion code to a dbEdit
> component which is linked to a DateField.  My code allows dates like "feb
3
> 1997", "19970203" & "N/A"

> Obviously, these formats can't be successfully inserted into a date
field,
> so I need to adjust them before Delphi attempts it.  How do I accomplish
> that?  I don't seem to be able to find the right event to attach the code
> to.

> In the case of the N/A response, I'd be changing the data to 01/23/45 (a
> date which I know I will never use, and which will therfore represent the
> N/A response in the database).  So when Delphi wants to display the
> contents of the database fields it needs to convert 01/23/45 to N/A
before
> doing so.  Again, which event do I latch onto for this.  

> Any help will be much appreciated.
> --
> David Jennings
> dav...@pacbell.net

Re:Adjusting dbEdit contents before update


David,

Quote
>>I'm trying to apply some enhanced date conversion code to a

dbEdit
component which is linked to a DateField.  My code allows dates
like "feb 3
1997", "19970203" & "N/A"<<

I develloped a component DBVldEdit Which is a Normal DBEdit with
some enhancements, as Validation(and adjusting) the field before
leaving it, MaskEdit property and Default value on creation of a
new record.

It can be found in the delphi forums and at Torry's Delphi pages

the name is DBVEDIT.zip

regards, Sjef van der Velde  

Other Threads