Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

ADODBGrid, locate and locatenext?

Hi,

I am using ADODBGrid.locate to retrieve records from an Access DB.
It is fine, but I now want to locate next record. How do I do this?


- Delphi 7 Pro
- Access 2000
- AdoDbGrid

thanks,
Christian
0
scholzfree
Asked:
scholzfree
  • 6
  • 6
1 Solution
 
kretzschmarCommented:
there is no locateNext,
use a filter instead of locate,
if you want to iterate through
all matching records

meikl ;-)

0
 
scholzfreeAuthor Commented:
Filter. How can I do this?

Thanks.
0
 
kretzschmarCommented:
adodataset.filter := 'SomeFieldName = SomeValue';
adodataset.filtered := true;

meikl ;-)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
scholzfreeAuthor Commented:
Filter. How can I do this?

Thanks.
0
 
scholzfreeAuthor Commented:
Hi,

my code:
dbgMain.DataSource.DataSet.Filter:='Text='+edFindKey.Text;
dbgMain.DataSource.DataSet.Filtered:=True;

but I get "Exception class EOleException. Arguments wrong type".




0
 
kretzschmarCommented:
well you mou must quote the value for stringfields,
access accepts doublequotes as far as i know

like
dbgMain.DataSource.DataSet.Filter:='Text="'+edFindKey.Text+'"';
dbgMain.DataSource.DataSet.Filtered:=True;

hope thats it

meikl ;-)


0
 
kretzschmarCommented:
where comes the mou from,
in my comment above :-))
0
 
scholzfreeAuthor Commented:
Hi,

no sorry. same exception.

Exception class EOleException with message:
'the arguments are of the wrong type,
lie outside of the range of validity or
are incompatible with one another'.

thanks
0
 
kretzschmarCommented:
well, what is text for a type?
0
 
scholzfreeAuthor Commented:
type for "Text" is text.
0
 
kretzschmarCommented:
ok, have done a test,
so it works for me:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if dbgrid1.DataSource.dataset.filtered then
    dbgrid1.DataSource.dataset.filtered := false
  else
  begin
    dbgrid1.DataSource.dataset.filter := 'Text = '+quotedstr(edit1.text);  //<-- single Quotes
    dbgrid1.DataSource.dataset.filtered := true;
  end;
end;

meikl ;-)
0
 
scholzfreeAuthor Commented:
Hi,

ok, it works fine,
but I need filteroption:=[foCaseInsensitive].
Then I get the message "filteroptions are not supported". :(

thanks,
Christian
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now