Solved

About Locate method - Very Easy. Part II

Posted on 2003-11-04
6
185 Views
Last Modified: 2010-04-05
I am using the following command but the Dbgrid doesn't focus on the cells.

Form2.DataSource1.DataSet.Locate('Number',Form5.Edit2.Text,
[loPartialKey]);

The locate command works fine with string fields. So does locate method works for numbers ?

If not, how can i get the same result ?
0
Comment
Question by:CodedK
  • 3
  • 3
6 Comments
 
LVL 16

Author Comment

by:CodedK
Comment Utility
I guess this happens because i haven't sort the table by the numbers.
Is that the case ?
0
 
LVL 5

Expert Comment

by:DeerBear
Comment Utility
Hi,

Try converting your text into a real number and use Locate on that.

HTH,

Andrew
0
 
LVL 16

Author Comment

by:CodedK
Comment Utility
I tried that. But the result is the same nothing is happening. I also sorted the dbgrid by the numbers but nopthing happened.

This is how i convert the string.

Form2.DataSource1.DataSet.Locate('NUMBER',StrToFloat(Form5.Edit2.Text),
[loPartialKey]);

Result is still the same.

Any ideas ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Accepted Solution

by:
DeerBear earned 40 total points
Comment Utility
Hi,

Try with:

var Num : Extended;

begin
  Num := StrToFloat(Form5.Edit2.Text);
  Form2.DataSource1.DataSet.Locate('NUMBER',[Num],[loPartialKey]);
end;

HTH,

Andrew

0
 
LVL 16

Author Comment

by:CodedK
Comment Utility
Ok the code code you gave me works. :)
I will accept your answer but answer this pls.

The result with : Form2.DataSource1.DataSet.Locate('NUMBER',[Num],[loPartialKey]);

is exactly the same with : Form2.Table1.FindKey([Form5.Edit2.Text]);

The problem here is that i want Partial Key to work. It doesnt work. I have to write the whole number to go to the right cell.

Do you know why this happens? Thank you for your previous answer DeerBear. I will get back and accept your answer but pls add a comment to that if you can.
Thanks.
0
 
LVL 5

Expert Comment

by:DeerBear
Comment Utility
Hi,

My guess is that loPartialKey works only with variable data like strings.
I don't think you can apply it to numbers.

The help about Locate doesn't specify if it's only for strings, but that's what I
have always assumed.

HTH,

Andrew
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now