Helpful Hint: DBLookUpCombo

Ok here is another helpful hint.  I will preface it with a disclaimer
that it may not be the correct or best way to do it BUT it works.  And
I also ask for a reply if there is a better way to do this.

Problem:  
Need a lookup combo on another lookup combo.  So as one changes the
other one refreshes with new values.  A simple and prehaps stupid
example might be:  a combo with State codes in it and a second combo
with Zip codes in it.  So when the State changes the Zip combo will
only contain valid zip codes for that State.  This won't happen no
matter how many times or different ways you rearrange the
properties...believe me I tried.

Solution:
 Much trial and error brought me this revelation.  Using the above
example as a reference, When the state changes it does not move or
access the table to which it is connected.  So the second one (the zip
codes) still is looking up based on what the State is pointing at
which is still the first record.  Solution to this is to do a find
whenever state changes.   Here is the code I used.

procedure TfrmItems.StateLookupComboChange(Sender: TObject);
begin
  With statetable do
  Begin
     Setkey;
     FieldByName('State').AsString := DBLookupCombo1.Text;
     GotoKey;
  End; {With}
  ZipLookUpCombo.Text := ''; {Erase any zip codes displayed since they
are now not valid}
end;

This code will effectivlely move the State table pointer thus allowing
the zip lookup combo to update.

I hope this help someone out there.  Again please note that the above
was just an example not real code :)  In other words don't tell me
there is a better way to do the above.  Iwas just trying to think of
an example that everyone could understand rather than use my own
specific code.

BTW I think this would be a good trend.  Start posting any Helpful
Hints you have run across.  Preface the title like above so they stand
out.

Eric Miles
mil...@usafe14.ramstein.af.mil
.............................................
My opinions and comments are my own and ONLY
my own and reflect in no way the Air Force's.
.............................................