Pass a TTable as Parameter to another object. 
Author Message
 Pass a TTable as Parameter to another object.

Hi,

I'd like to edit a field from a database, passed as parameter, in an
other object. But whenn I try to store the modifications I get an
EAccess Violation.

Example: MyEditor shows the contents of the Field MyField in MyTable.

I pass it:  MyEditor.ShowModal(self,MyTable, MyField) ;

Implementation:

procedure TEditor.ShowModal(Sender: TObject; tab: TTable; source:
TField);
begin
  inherited ShowModal;
  FName := source;                      // local var
  TabName := tab;                       // local var
  RichEdit1.Lines.Assign(source);       // TRichEdit component
end;

procedure TEditor.SaveMemo(Sender: TObject);
begin
  if TabName.State = dsInactive then TabName.Active := True;  // ***
  TabName.Edit;
  FName.SetFieldType(ftFmtMemo);
  FName.Assign(RichEdit1.Lines);
  TabName.Post;
end;

*** Here I get an EAccess Violation

What did I wrong? Is there another possibility to solve this problem?

Thanks for any hint!
Andi
--
Andreas Strebel                                      
Chemin des Cotes 1, CH-1020 Renens
Phone ++41 21 636 26 41

http://www.*-*-*.com/ ~strebel



Fri, 04 Jun 1999 03:00:00 GMT  
 Pass a TTable as Parameter to another object.

Quote:

>procedure TEditor.ShowModal(Sender: TObject; tab: TTable; source:
>TField);
>begin
>  inherited ShowModal;
>  FName := source;                      // local var
>  TabName := tab;                       // local var
>  RichEdit1.Lines.Assign(source);       // TRichEdit component
>end;

I may be wrong here, but isn't your variable initialized after your
screen has been displayed and exited.  Try the inherited ShowModal
after the variable setups.  (Or something like that)

FWIW
Mel Rees



Sun, 06 Jun 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing a TField object as a parameter?

2. Passing parameters to stored procedure.

3. Passing Parameters to an Update Query

4. Parameter Query not passing Param

5. Passing TMemoField as a TStringList parameter to a procedure

6. Access 97 report from Delphi and passing parameters

7. passing SQL parameters

8. Passing functions as parameters in Turbo Pascal

9. Passing Sql parameters Help

10. Passing NULL parameters to a stored procedure

11. How to pass parameter to TQuery and retrieve value from TQuery

12. Passing indefinite number of parameters

 

 
Powered by phpBB® Forum Software