Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If a value entered on a form = value saved in a record on another form

Status
Not open for further replies.

spik3ee

Technical User
Feb 5, 2009
1
Hi, first post =)

Basically i have two forms in my application,
and one form contains a record & a save procedure

type
TShares = record
Name : string[20];
Profession : string[20];
Location : string[50];

var
Records : array[1..50] of TShares;

procedure Save(RecordNo : integer);
begin
Records[RecordNo].name := Edt_name.Text;
Records[RecordNo].profession := Edt_Name.Text;
Records[RecordNo].location := Edt_Address.text;
end;


Now what i want to do is,
when i enter a name on my second form, i want to check whether the name exists in the array, and if so, display the data for that particular record.

im thinking
If Edt_Name.text = Frm1.Records[RecordNo].name then
however ofcourse RecordNo is underlined in red, even though i'ev put my save procedure under public declarations

any help?
 
when i enter a name on my second form, i want to check whether the name exists in the array
With you your particular data structure, I think your only choice is to iterate through the array of records, looking for a match between "Edt_Name.text" and "Frm1.Records[RecordNo].name".

Have you considered using an actual database? Then there would be more elegant approaches available.

Since it's you 1st post, you should know it's customary to put your code between [ code] (your code here) [ /code] tags. (Without the spaces after the '[') like this:
Code:
  for RecordNo:= 1 to 50 do
    if Edt_Name.text = Frm1.Records[RecordNo].name then begin
      FillEditBoxes;  //record already exists
      exit
    end;
Welcome to the forum!

Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top