![]() |
AW: Access variable from one form to another
I think we need the code of the "Person1"-method. Maybe you want to do a call by reference but actually do a call by value?
|
AW: Access variable from one form to another
The PersonID can alternatively be determined from a query:
Delphi-Quellcode:
unit unit1;
interface type TForm1 = class(TForm) {...} private // <- for use self function GetMyPersonID: Integer; procedure SetMyPersonID(AValue: Integer); public // <- for use to other property MyPersonID: Integer read GetMyPersonID write SetPersonID; end; var Form1: TForm1; // <- Instance of TForm1 implementation procedure TForm1.SetMyPersonID(AValue: Integer); begin FQuery.FieldByName('MyPersonID').AsInteger := AValue; end; procedure TForm1.GetMyPersonID: Integer; begin Result := FQuery.FieldByName('MyPersonID').AsInteger; end; |
AW: Access variable from one form to another
Hi,
i have followed what you have suggested but i still got the value '0' . Now, i wanna do the work in same Unit mot from another
Code:
Procedure TForm1.AddDateTime(Sender:Tobject; AEvent: TcxSchedulerEvent);
begin Query.Close(); QueryKalender.SQL.Text:= 'INSERT INTO Table' '(Name`, `NEWID` ..) ' + 'VALUES ( ' :Name, :NEWID);'; Query.ParamByName('NEWID').AsInteger:= AEventID; Query.ExecSQL(); Query.Close(); end; Procedure TForm1.OnDragDrop(Sender, Source: TObject; X, Y: Integer); begin //here i would like to use the value of AEventID; //i cannnot call the procedure AddDateTime(Sender,TcxSchedulerEvent); //becasue the parameter is different, how can i overcome it ? end; |
AW: Access variable from one form to another
Hi, now its working fine :) i have written the follwoing
Code:
is that ok to write like this, i mean normally in sql query need to query.sql.add/query.sql.open/close... but in this case it is working fine should i need to write the whole query or is that also okay just to write only
procedure TForm1.SetMyPersonID(AValue: Integer);
begin FQuery.FieldByName('MyPersonID').AsInteger := AValue; end; procedure TForm1.GetMyPersonID: Integer; begin Result := FQuery.FieldByName('MyPersonID').AsInteger; end;
Code:
Result := FQuery.FieldByName('MyPersonID').AsInteger;
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz