Board index » delphi » Record NOT Found

Record NOT Found

Hi

I have two DBComboboxes linked to two datasources which in turn are then
linked to two tables

I am using the first datasource/table as the mastersource for the second
so when the value of the first combobox changes, the items in the second
follow suit.

My problem is with the feature that allows you to press a key to
automatically jump to the nearest matching record. e.g. If I press D the
combobox should jump to the first record beginning with D.

This works if I am on the first record of the master table. I can press
a key in the second combobox and get the desired results.
However if I select a different value in the first combobox (thereby
moving of of the first record) when I drop down the second combobox and
press a key I get the error "Record NOT Found"

I have had a quick look at the VCL source but cant really find what I'm
looking for. I am using Delphi 3.

Anybody seen this before or know how to fix it !!!

Regards
Dom

 

Re:Record NOT Found


Hello,

for an incremental search you could put the following codeline in
DBComboBox1.OnChange event:

Table1.FindNearest([DBCombobox1.Text]);

:)
Kai Inge

Quote
"Dominic Garner" <D...@keyit.demon.co.uk> wrote in message

news:398E8809.A051B740@keyit.demon.co.uk...
Quote
> Hi

> I have two DBComboboxes linked to two datasources which in turn are then
> linked to two tables

> I am using the first datasource/table as the mastersource for the second
> so when the value of the first combobox changes, the items in the second
> follow suit.

> My problem is with the feature that allows you to press a key to
> automatically jump to the nearest matching record. e.g. If I press D the
> combobox should jump to the first record beginning with D.

> This works if I am on the first record of the master table. I can press
> a key in the second combobox and get the desired results.
> However if I select a different value in the first combobox (thereby
> moving of of the first record) when I drop down the second combobox and
> press a key I get the error "Record NOT Found"

> I have had a quick look at the VCL source but cant really find what I'm
> looking for. I am using Delphi 3.

> Anybody seen this before or know how to fix it !!!

> Regards
> Dom

Re:Record NOT Found


Thanks for the reply

The 1st combobox autosearch ALWAYS works OK, Its the second one that
generates the error. If I was to implement your suggestion, how would I
override the default behaviour which is to jump to the nearest match

Dom

Re:Record NOT Found


Hello again,

I would have used two editfields and two dbgrids, instead of DBComboboxes.
Then you have free hands with indexing, filtering and can control the
behavior yourself.
I never use Master/Detail properties, but put the searching line
Table2.FindNearest([Table1.Fieldbyname('MYFIELD').Asstring;
 in OnDataChange event of the DataSource1. Then table2 will follow table1
and you can put
Table2.FindNearest([Edit2.Text]);
in Edit2.OnDataChange, and
Table1.FindNearest([Edit1.Text]);
in Edit1.OnDataChange events to separately search the two tables.
Then you have the same function as if you had used the tables Master/Detail
properties and can still search them separately without problems.

:)
Kai Inge

Quote
"Dominic Garner" <D...@keyit.demon.co.uk> wrote in message

news:398EBA7A.911343C4@keyit.demon.co.uk...
Quote
> Thanks for the reply

> The 1st combobox autosearch ALWAYS works OK, Its the second one that
> generates the error. If I was to implement your suggestion, how would I
> override the default behaviour which is to jump to the nearest match

> Dom

Re:Record NOT Found


Hi

Thanks again for your help.

Unfortunately, I need the drop downs to limit the data that can be
entered, however you have given me another thought, maybe instead of the
Master/Detail I could use cancelrange & setrange to mimic the behaviour
I'm after, and hopefully it wont generate a {*word*193} error

Regards
Dom

Re:Record NOT Found


Hello again,

I also like to use filters to achieve a Master/Detail behavior. Then you
also get a 'multi select' effect, as several records in Table2 grid gets
visible because they belong to one record in Table1. (I.e. have a field
content in common.) You set the filter in DataSource1.OnDataChange event:
Table2.Filter := 'MYFIELD = ' Table1.Fieldbyname('MYFIELD').Asstring;
Table2.Filtered := True;
Remember to set Table2.Filtered := False; if you want to do a incremental
search on it.

If you want to do a incremental search on Table1: In the
DataSource1.OnDataChange event wrap the filter setting in a
If FilterSettingOk then . . . to get able to 'shut it off' to increase the
speed of the incremental search, and on again when hitting the intended
record in Table1. Otherwise the typing of the search item will be in slow
motion.

:)
Kai Inge

Quote
"Dominic Garner" <D...@keyit.demon.co.uk> wrote in message

news:398EDF7B.FD81DA00@keyit.demon.co.uk...
Quote
> Hi

> Thanks again for your help.

> Unfortunately, I need the drop downs to limit the data that can be
> entered, however you have given me another thought, maybe instead of the
> Master/Detail I could use cancelrange & setrange to mimic the behaviour
> I'm after, and hopefully it wont generate a {*word*193} error

> Regards
> Dom

Other Threads