Re: DBLookupComboBox question



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
.



Relevant Pages

  • Re: No smooth transition to the next form
    ... I am reading the textfile line by line. ... same string after the blank spaces. ... > I'm not sure how you're populating your combo boxes but you get the idea. ... So I am calling the same function for Saving in the ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: FileDialog browse button: how do you specify the default directory
    ... If not, it's just a dialogue, not a saving ... Sub GetFile ... Dim retFile As String, dlg As Variant, s As String ...
    (microsoft.public.access.formscoding)
  • Re: rich text format
    ... If I'm saving the string to a database and displaying it using a quickrep, ...
    (alt.comp.lang.borland-delphi)
  • Re: Whats the most efficient to check a file name is valid?
    ... conditional formatting in each visible cell. ... At the moment I copy the use provided file name into a string and don't use ... >> As" dialogue just spits back whatever it's given. ... >>> I'd just try saving the workbook with that name and see if there was an error. ...
    (microsoft.public.excel.programming)