Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

About Locate method - Very Easy. Part II

Posted on 2003-11-04
6
Medium Priority
?
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 16

Author Comment

by:CodedK
ID: 9683744
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
ID: 9686042
Hi,

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

HTH,

Andrew
0
 
LVL 16

Author Comment

by:CodedK
ID: 9687433
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
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.

 
LVL 5

Accepted Solution

by:
DeerBear earned 160 total points
ID: 9687449
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
ID: 9688183
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
ID: 9692513
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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