Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Lookup and m/d
Mon, Nov 23 2009 4:13 AMPermanent Link

"Sorin H"
Hello Tim

I try to isolate only the parts that demonstrate the problem.

The problem is that on the dbgrid the lookupField "LkpRepairDtl"  is blank
in spite of
the fact that the field "RepairDtlId" have values.

Thanks for the support
Sorin






Attachments: Unit2.pas Unit2.dfm
Mon, Nov 23 2009 4:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin


That will never work. I can see   tbCarRepair.Open; but there's no open statement for the other table.

Roy Lambert [Team Elevate]
Mon, Nov 23 2009 6:28 AMPermanent Link

"Sorin H"
"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
>
> That will never work. I can see tbCarRepair.Open; but there's no open
> statement for the other table.

Thanks

1 I thought that tables that are used only for lookup fields are open auto.
and
  the values from tbTblRepair table indeed appear on the dbgrid.
2 For safety I open all the tables but the same problem remain.

Sorin

Mon, Nov 23 2009 7:23 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin


Can you post the catlog and tables you're using as well please.

Roy Lambert [Team Elevate]
Mon, Nov 23 2009 10:35 AMPermanent Link

"Sorin H"
> Can you post the catlog and tables you're using as well please.

I post only the relevant one. Hope it's enough.
Sorin















Attachments: EDBDatabase.EDBLck EDBConfig.EDBCfg EDBConfig.EDBLck EDBConfig.EDBLog EDBDatabase.EDBCat MCarRepair.EDBTbl MCarRepair.EDBIdx MTblRepair.EDBIdx MTblRepair.EDBTbl MTblRepairDtl.EDBIdx MTblRepairDtl.EDBTbl
Wed, Nov 25 2009 4:25 AMPermanent Link

"Sorin H"
The app have a company table with company name, city and street.
The cities and street come from 2 tables that have m/d relation.

I want to insert a record write the company name, select the city and select
the street that belong to the selected city.

Thanks for the support
Sorin





Attachments: LookUp.zip
Sat, Nov 28 2009 2:34 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Sorin,

<< The app have a company table with company name, city and street. The
cities and street come from 2 tables that have m/d relation.

I want to insert a record write the company name, select the city and
select the street that belong to the selected city. >>

The problem is that you are expecting a lookup field to move the record
pointer in the target lookup table, which is not the case.  A lookup simply
does the lookup and leaves the current record pointer intact.  What you want
to do instead is make the fields calculated fields, and perform the lookup
by using FindKey/Locate in an OnCalcFields event handler.

procedure TForm2.tbCompanyCalcFields(DataSet: TDataSet);
begin
  if tbCity.Locate('ID',tbCompanyCityID.AsString,[]) then
     tbCompanyLkpCity.AsString:=tbCityCity.AsString
  else
     tbCompanyLkpCity.AsString:='Not found';
  if tbStreet.Locate('ID',tbCompanyStreetID.AsString,[]) then
     tbCompanyLkpStreet.AsString:=tbStreetStreet.AsString
  else
     tbCompanyLkpStreet.AsString:='Not found';
end;

--
Tim Young
Elevate Software
www.elevatesoft.com

Sun, Nov 29 2009 2:55 AMPermanent Link

"Sorin H"
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
> procedure TForm2.tbCompanyCalcFields(DataSet: TDataSet);
> begin
>   if tbCity.Locate('ID',tbCompanyCityID.AsString,[]) then
>      tbCompanyLkpCity.AsString:=tbCityCity.AsString
>   else
>      tbCompanyLkpCity.AsString:='Not found';
>   if tbStreet.Locate('ID',tbCompanyStreetID.AsString,[]) then
>      tbCompanyLkpStreet.AsString:=tbStreetStreet.AsString
>   else
>      tbCompanyLkpStreet.AsString:='Not found';
> end;

Wow,  why I didn't think about it?

Thanks Tim

Image