Re: DBLookupComboBox question
- From: DB-1 <db1@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 27 Oct 2005 17:41:39 +0300
swansnow wrote:
>
>
> Now, I'm guessing it has something to do with the fact that I'm saving
> to an integer field (the recordID), so it doesn't know what to display.
> I would rather not put a name field into table2 since it's not needed
> and could cause confusion in the future.
If I understand even close what you are trying to do, then maybe using
the Field's SetText and GetText events could be some kind of a solution
to turn those Integer values back to visible Strings again on screen.
procedure TForm1.Table2CathegoryIdSetText(Sender: TField;
const Text: String);
// Instead of saving the Cathegory String value from Table1, to Table2
// store only the CathegoryId integer valus to the database.
begin
(Sender as TSmallIntField).AsInteger := Table1.CathegoryId.AsInteger;
end;
procedure TForm1.Table2CathegoryIdGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
// Read the stored Id integer number, and show on screen
// the corresponding Cathegory text.
begin
if Table1.FindKey([(Sender as TSmallIntField).AsInteger])
then Text:= Table1.FindKey.FieldByName('Cathegory').AsString
else Text:= ''
end;
It was too big a task to start building equivalent test environment with
the same Tables an Field types etc, so I did not test this suggestion,
not even tried to compile it at all. If this hack brings some new idea
what you could try to do, then that's fine. Yet if it is garbage that
won't fit to this situation, then it's garbage anyway<g>.
DB1
.
- Follow-Ups:
- Re: DBLookupComboBox question
- From: swansnow
- Re: DBLookupComboBox question
- References:
- DBLookupComboBox question
- From: swansnow
- DBLookupComboBox question
- Prev by Date: Re: DBLookupComboBox question
- Next by Date: Re: DBLookupComboBox question
- Previous by thread: Re: DBLookupComboBox question
- Next by thread: Re: DBLookupComboBox question
- Index(es):
Relevant Pages
|