Recent

Author Topic: [SOLVED]Problem with Traversing active Records in a table with TDBLookupCombobox  (Read 2367 times)

BeesKnieg

  • Newbie
  • Posts: 4
Hi Guys

I want the values in the groupbox (from the attached picture) to change as I select a resident's last name from the DBLookupCombobox. Currently the values in the groupbox only change when I click on another record in the DBGrid or use the DBNavigator on the bottom of the form.

DataSource and DataField values for the DBLookupCombobox is empty
ListSource for DBLookupCombobox has the same datasource as the DBGrid and DBNavigator
ListField and KeyField values for the DBLookupCombobox has the same value (ResidentLName)

I feel like I'm missing something small here.

Thanks

Code: [Select]
procedure TfrmEditStudentActivities.FormShow(Sender: TObject);
begin

  DataModule1.ResidentsSQLQuery1.Close;
  DataModule1.ResidentsSQLQuery1.SQL.Text:= 'SELECT * FROM resident2 ' +
                                                    'ORDER BY ResidentLName';

  DataModule1.ResidentsSQLQuery1.Open;

end;
« Last Edit: October 16, 2014, 10:25:31 pm by BeesKnieg »
Lazarus 1.2.6/FPC 2.6.4/Win 32  (on Win 7/32 bit)

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: Problem with Traversing active Records in a table with TDBLookupCombobox
« Reply #1 on: October 16, 2014, 09:47:02 pm »
You are not giving us enough information - but let's see....

I assume first names & resident IDs are displayed via TDBTexts?

You intend to use the TDBLookupcombo for navigational purposes - i.e., by selecting a value you expect the dbgrid to scroll to the matching value and the 2 dbtexts to be updated accordingly?

Your UI makes no sense to me - is the grid only there for debugging purposes?
« Last Edit: October 16, 2014, 09:48:41 pm by kpeters58 »
Lazarus 2.0.4/FPC 3.0.4/Win 64

BeesKnieg

  • Newbie
  • Posts: 4
Re: Problem with Traversing active Records in a table with TDBLookupCombobox
« Reply #2 on: October 16, 2014, 09:55:50 pm »
Hi kpeters58

That is correct, yes. first names & resident IDs are displayed via TDBTexts. They change as I use the DBNavigator or click on another record in the DBGrid.

And yes, I want to use the DBLookupComboBox for navigational purposes.

ie. I want the TDBTexts to update when I select a "lastname" from the DBLookupComboBox which they are not doing at the moment.

What other information can I add?
Lazarus 1.2.6/FPC 2.6.4/Win 32  (on Win 7/32 bit)

BeesKnieg

  • Newbie
  • Posts: 4
Re: Problem with Traversing active Records in a table with TDBLookupCombobox
« Reply #3 on: October 16, 2014, 10:00:09 pm »
Yes, the DBGrid and DBNavigator is only there for debugging reasons - To show that the DbEdits update when I click on records and use the navigator, but fail to update when I select a "lastname" from the DBLookupComboBox

Edit:

The picture posted shows the DBEdits displaying data from the active record in the grid. The "lastname" that was selected in the DBLookupComboBox does not match the "lastmane" from the active record from the grid
.
« Last Edit: October 16, 2014, 10:05:13 pm by BeesKnieg »
Lazarus 1.2.6/FPC 2.6.4/Win 32  (on Win 7/32 bit)

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: Problem with Traversing active Records in a table with TDBLookupCombobox
« Reply #4 on: October 16, 2014, 10:04:30 pm »
DBLookupCombo.ScrollListDataset ? Scroll event?

See unbound use here:

http://wiki.freepascal.org/dblookupcombobox
« Last Edit: October 16, 2014, 10:16:16 pm by kpeters58 »
Lazarus 2.0.4/FPC 3.0.4/Win 64

BeesKnieg

  • Newbie
  • Posts: 4
Re: Problem with Traversing active Records in a table with TDBLookupCombobox
« Reply #5 on: October 16, 2014, 10:17:19 pm »
Ah there we go. Seems like that was the thing I was missing. Taking into account the time I've spent trying to figure this out before I actually asked, I won't forget to set DBLookupCombo.ScrollListDataset to true any time soon :).

Everything works as it should now.

Thanks so much kpeters58.
« Last Edit: October 16, 2014, 10:23:06 pm by BeesKnieg »
Lazarus 1.2.6/FPC 2.6.4/Win 32  (on Win 7/32 bit)