> I'm developing an Application that confronts two person e their born dates and,
> to do this, i have two ComboBoxes for the names that i get in a name field's
> table e to a MaskEdit that receives it's Born Date.
>I'm doing this :
> // to put tha names available in the database in the comboboxes :
> procedure TFrmAfinidades.FormActivate(Sender: TObject);
> begin
> TblPersons.Active := True;
> TblPersons.Active := True;
> TblPersons.Open;
> TblPersons.First;
> While not TblPersons.eof do begin
> Combo_FirstName.Items.Add(TblPersonsName.Value);
> Combo_SecondName.Items.Add(TblPersonsName.Value);
> TblPersons.Next;
> end;
> end;
"TblPersons.Active := True;" is the same as "TblPersons.Open;"
Also I'd remove the need for persistent fields.
Combo_FirstName.Items.Add(TblPersons.FieldByName("FirstName").AsString);
Combo_LastName.Items.Add(TblPersons.FieldByName("LastName").AsString);
(although the logic of loading these into separate Combos seems wrong...)
> My intention is, when the Combo_FirstName changes to a name, the
> corresponding Born_Date's field have to fill the MaskEdit_BornDate1 and when
> the Combo_SecondName changes to a name, the corresponding Born_Date's
> field have to fill the MaskEdit_BordDate2.
> i have tried to do many things like :
> 1 - Combo_FirstName.OnExit or Combo_FirstName.Onchange :
> MaskEdit_BornDate1.Text := DateToStr(TblPersonsBornDate.Value);
This will load the BornDate of the record the TTable is currently looking at into the
MaskEdit (as will the second example).
TblPerson.FindKey([Combo_FirstName.text,Combo_LastName.text]);
MaskEdit_BornDate1.Text := DateToStr(TblPersons.FieldByName("BornDate").AsDate);
(I'd recommend using FormatDateTime rather than DateToStr so you can ensure the
date format matches your maskedit format).
> But what is going wrong ???? The BornDate everytime is the BornDate of the last
>record.
That's the way things work... The table doesn't know which record you want, it's
pointing to
where you left it - at the end of the table.
--
Aaron@home
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"