Board index » delphi » Pre FIlling Fields in a TTable Record from last posted record

Pre FIlling Fields in a TTable Record from last posted record

I have a data entry application where about 70 percent of the fields
from one entry to the next are _usually_ the same.  When the user
presses the 'add record' button, I's like to fill those fields with
the contents of the record most recently posted.

I am considering using the recordsize property of TTable to copy the
whole record into a buffer prior to posting, then copying it back
(to what??) when the add button is pushed.

Does anybody have a nice way of doing this?

Thanks.

--
Wayne Herbert
Manager, Computer Products
Key Maps, Inc.
1411 West Alabama
Houston, TX  77006

Vox:  713.522.7949
Fax:  713.521.3202
Email:  wherb...@keymaps.com

"How can we POSSIBLY use sex to get what we want?  Sex IS what we
want!"
     --Dr. Frasier Crane

 

Re:Pre FIlling Fields in a TTable Record from last posted record


You could copy the record of your last record (to have focus) in the OnEnter
event of your Add button, it fires before your Click does...

--
Michael Glatz
mgl...@caiso.com

Quote
Wayne Herbert wrote in message <36FA6124.B1B0F...@keymaps.com>...
>I have a data entry application where about 70 percent of the fields
>from one entry to the next are _usually_ the same.  When the user
>presses the 'add record' button, I's like to fill those fields with
>the contents of the record most recently posted.

>I am considering using the recordsize property of TTable to copy the
>whole record into a buffer prior to posting, then copying it back
>(to what??) when the add button is pushed.

>Does anybody have a nice way of doing this?

>Thanks.

>--
>Wayne Herbert
>Manager, Computer Products
>Key Maps, Inc.
>1411 West Alabama
>Houston, TX  77006

>Vox:  713.522.7949
>Fax:  713.521.3202
>Email:  wherb...@keymaps.com

>"How can we POSSIBLY use sex to get what we want?  Sex IS what we
>want!"
>     --Dr. Frasier Crane

Re:Pre FIlling Fields in a TTable Record from last posted record


Yes, but from where and to where... Table1.??? =

Quote
Michael Glatz wrote:
> You could copy the record of your last record (to have focus) in the OnEnter
> event of your Add button, it fires before your Click does...

> --
> Michael Glatz
> mgl...@caiso.com
> Wayne Herbert wrote in message <36FA6124.B1B0F...@keymaps.com>...
> >I have a data entry application where about 70 percent of the fields
> >from one entry to the next are _usually_ the same.  When the user
> >presses the 'add record' button, I's like to fill those fields with
> >the contents of the record most recently posted.

> >I am considering using the recordsize property of TTable to copy the
> >whole record into a buffer prior to posting, then copying it back
> >(to what??) when the add button is pushed.

> >Does anybody have a nice way of doing this?

> >Thanks.

> >--
> >Wayne Herbert
> >Manager, Computer Products
> >Key Maps, Inc.
> >1411 West Alabama
> >Houston, TX  77006

> >Vox:  713.522.7949
> >Fax:  713.521.3202
> >Email:  wherb...@keymaps.com

> >"How can we POSSIBLY use sex to get what we want?  Sex IS what we
> >want!"
> >     --Dr. Frasier Crane

--
Wayne Herbert
Manager, Computer Products
Key Maps, Inc.
1411 West Alabama
Houston, TX  77006

Vox:  713.522.7949
Fax:  713.521.3202
Email:  wherb...@keymaps.com

"How can we POSSIBLY use sex to get what we want?  Sex IS what we want!"
     --Dr. Frasier Crane

Re:Pre FIlling Fields in a TTable Record from last posted record


On Thu, 25 Mar 1999 14:33:59 -0600, Wayne Herbert <wherb...@keymaps.com>
wrote:

Quote
>Yes, but from where and to where... Table1.??? =

One way would be to use a second TTable component that points to the same
base table. Prior to inserting a new record, such as in a handler for the
BeforeInsert event, you could use the TTable.GotoCurrent method of this
second TTable to put its record pointer to the same record as is current in
the TTable through which you are going to insert a new record. Then, after
the insert has been effected but before the user can start editing, such as
in a handler for the OnNewRecord event, you can copy the values from all or
just selected fields from the second TTable (still on the old record) to
the newly inserted record in the main TTable.

For example:

  procedure TForm1.MainTableBeforeInsert(DataSet: TDataSet);
  begin
    SecondTable.GotoCurrent(MainTable);
  end;

  procedure TForm1.MainTableNewRecord(DataSet: TDataSet);
  begin
    DataSet.Fields[0].AsString := SecondTable.Fields[0].AsString;
    DataSet.Fields[1].AsInteger := SecondTable.Fields[0].AsInteger;
    ...
  end;

It really depends on what you count as the "last" record from which to copy
the field values to the new record. Another approach would be to use a
handler for the main TTable component's AfterPost event and, in this event
handler, use GotoCurrent on the second, ghost TTable to synchronize its
record pointer with the last posted record in the main TTable.

//////////////////////////////////////////////////////////////////////////
Steve Koterski                    "My problem lies in reconciling my gross
Technical Publications            habits with my net income."
INPRISE Corporation                             -- Errol Flynn (1909-1959)
http://www.borland.com/delphi

Re:Pre FIlling Fields in a TTable Record from last posted record


Another option, in addition to Steve's suggestion, is to copy the fields of
the record to a variant array in the AfterPost event handler. In the
OnNewRecord event handler copy the field values from the array to the fields
in the new record.

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to email questions. To contact me
 for any other reason remove nospam from my address.)

Other Threads