Board index » delphi » A couple of questions

A couple of questions

1.  Does anyone have any hints for working with memo fields in tables?
   Specifically, how can I copy a memo in one table to another.  With
   a string I would use table1.fieldByName('strField').asString:=
                            table2.fieldByName('stuff').asString;

2.  Is there a way to dynamically create a tTable component at runtime
    in a unit that doesn't have a corresponding form?

Thanks,
Brian

 

Re:A couple of questions


Quote
Brian Clark <br...@qcomm.com> wrote:
>1.  Does anyone have any hints for working with memo fields in tables?
>   Specifically, how can I copy a memo in one table to another.  With
>   a string I would use table1.fieldByName('strField').asString:=
>                        table2.fieldByName('stuff').asString;

>2.  Is there a way to dynamically create a tTable component at runtime
>    in a unit that doesn't have a corresponding form?

>Thanks,
>Brian

Here's the answer to #2.

Procedure Whatever;
Var
  MyTable : TTable;

Begin

  MyTable := TTable.Create(Application);
  MyTable.DataBaseName := { Alias or Database Name... };
  MyTable.TableName := 'mytable';

End; { Whatever }

Re:A couple of questions


Quote
Brian Clark <br...@qcomm.com> wrote:
>1.  Does anyone have any hints for working with memo fields in tables?
>   Specifically, how can I copy a memo in one table to another.  With
>   a string I would use table1.fieldByName('strField').asString:=
>                        table2.fieldByName('stuff').asString;

I have found that using memory streams is the simplest way to work
with memos.  Here is an example procedure.  It will append a message
from a "Purchase Order Message Library" to the current "Purchase Order
Message" memo field:

procedure TfrmPOMaint.AppendMsg(Sender: TObject);
var
    S              : TMemoryStream;

begin
   if tblPOMsg.State in [dsInsert, dsEdit] then tblPOMsg.Post;
   tblPOMsg.Edit;
   S := TMemoryStream.Create;
   try
      if fldPOMessage.TextLength > 2 then
tblPOMsgMessage.SaveToStream(S);
      tblMsgLibMessage.SaveToStream(S);
      tblPOMsgMessage.LoadFromStream(S);
      fldPOMessage.Refresh;
   finally
      S.Free;
   end;
end;

Quote
>snip<

Hope this helps,

Phil
"Due to recent cutbacks, the light at the end of the tunnel has been
turned off."

Other Threads