Helpful Hint: DBLookUpCombo 
Author Message
 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

.............................................
My opinions and comments are my own and ONLY
my own and reflect in no way the Air Force's.
.............................................



Sat, 25 Jul 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Helpful Hint: Auto magically generating SQL statements

2. DB Alias not helpful

3. Thanks for all the helpful responses (to the prime number question)

4. helpful new florida website

5. helpful new florida website

6. Some helpful information...

7. C/S Hints Needed.

8. TechTips: Hints for faster processing of large updates

9. Delphi 4 Hint at design time

10. TTreeView Object's Hint

11. DBNavigator hints...

12. MSAccess->Delphi experiences,hints?

 

 
Powered by phpBB® Forum Software