You're creating your object in the initialization area; I don't see where it is cleared.
jhg -----Original Message----- From: advanced_delphi@yahoogroups.com on behalf of nf4lham Sent: Sat 5/31/2008 7:45 PM To: advanced_delphi@yahoogroups.com Subject: [advanced_delphi] Persistant values shouldn't be I call a method in another unit (dbUnit) to retrieve a record from a database. On a successful query another method in dbUnit fills a record type to be passed back to the calling unit. dbUnit looks like this unit dbUnit; interface uses SysUtils, Classes, Windows, Variants, DAO_TLB, dialogs, comObj; type TMyCustRec = packed record fname: string; lname: string; end; type TMyDBU = class(TObject) private public function GetCurrCustomer: TMyCustRec; end; var DBU: TMYDBU; implementation function MdbU.GetCurrCustomer: TMyCustRec; begin result.lname := CustRec.Fields['l_name'].Value; result.fname := CustRec.Fields['f_name'].Value; end; initialization DBU := TMYDBU.Create; end. The call from the main unit is like: procedure GetaCustomer; var retrec: TMyCustRec; begin retrec := DBUnit.DBU.GetCurrCustomer; end; On subsequent calls, result.lname & result.fname are still populated with values from the previous call.They're acting like global variables. Why? Thanks, Mike
<<winmail.dat>>