nf4l: A few questions and a suggestion: The suggestion first... Before you call your GetaCustomer, clear the target variables. result.lname := ''; result.fname := ''; result.lname := CustRec.Fields['l_name'].Value; result.fname := CustRec.Fields['f_name'].Value; If the values come back with the same text as a previous call, you will know that the problem resides in the dataset manipulation and not in your calling code. Here are the questions... * Are you sure you are moving your dataset to the next record or to some new record? I don't see any code that moves or changes the cursor position in your dataset. * Are you sure the variables from your dbUnit aren't global? If the calling unit has dbUnit in its uses clause, then it might as well be a global variable. The code you use to call dbUnit doesn't do anything to dispose of it and unless dbUnit is created and called dynamically (where it would be destroyed after use), it's going to retain the values it That's all I can see to ask without seeing more of the code. I hope this helps... XFX nForce 680i LT SLI Socket 775 | Intel Core 2 Duo E6750 OC:1600 FSB @ 3.2 MHz | 2 x OCZ SLI 1024MB PC6400 DDR2 800MHz| XION 600w PSU | CM Stacker 200 ATX/BTX Case | EVGA GeForce 8800 GTS 512 | WD SATA 74 GB Raptor (boot,system), WD SATA 500 GB (storage) | Windows XP Pro, SP2 | Patient and supportive significant other
To: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Sun, 1 Jun 2008 02:45:54 +0000Subject: [advanced_delphi] Persistant values shouldn't be I call a method in another unit (dbUnit) to retrieve a record from adatabase.On a successful query another method in dbUnit fills a record type tobe passed back to the calling unit. dbUnit looks like thisunit dbUnit;interfaceusesSysUtils, Classes, Windows, Variants, DAO_TLB, dialogs, comObj;typeTMyCustRec = packed recordfname: string;lname: string;end;typeTMyDBU = class(TObject)privatepublicfunction GetCurrCustomer: TMyCustRec;end;varDBU: TMYDBU;implementationfunction MdbU.GetCurrCustomer: TMyCustRec;beginresult.lname := CustRec.Fields['l_name'].Value; result.fname := CustRec.Fields['f_name'].Value;end;initializationDBU := TMYDBU.Create;end.The call from the main unit is like:procedure GetaCustomer;varretrec: TMyCustRec;beginretrec := DBUnit.DBU.GetCurrCustomer;end;On subsequent calls, result.lname & result.fname are still populatedwith values from the previous call.They're acting like globalvariables. Why?Thanks,Mike _________________________________________________________________ Keep your kids safer online with Windows Live Family Safety. http://www.windowslive.com/family_safety/overview.html?ocid=TXT_TAGLM_WL_Refresh_family_safety_052008