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

x
?
Solved

ADO Table and locate

Posted on 2010-09-12
7
Medium Priority
?
731 Views
Last Modified: 2012-05-10
I have the following problem. I am getting data from my serial port and I am adding it into a Access table but as the data comes in I use the locate function to lookup the customer ID to display it in a label but the problem is when I want to add/edit a record on that table it is opened and closed by the locate function. Is there maybe a work around this?
0
Comment
Question by:DigitalNam
[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
7 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 33657319
Calling Locate does not close an ADO Table or any other dataset, you have some other action that is closing your tables.

What dou you do immediately after you call Locate?
0
 
LVL 1

Author Comment

by:DigitalNam
ID: 33657343
The closing isn't the problem. While adding a new client to the database the data on the input form shows the current record that is shown with the locate function. the data from the serial port is received every 1 second so while you are entering new information it jumps back to the customer that is being located.
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 33657541
Thats the default behaviour of the dataset, when a new record is inserted, the dataset sets it as the current record, so it jumps to that record.

Create a record holder for your edits, once your are done adding or editing the record, apply the changes to the live dataset
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:DigitalNam
ID: 33657576
please explain record holder.
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 33657633
type
  PDataRecord = ^TDataRecord
  TDataRecord = record
    ID: Integer;
    FirstName: string;
   //Other fields
  end;

procedure UpdateDataset(ADataset: TDataset; PData: PDataRecord; AUpdateKind: TUpdateKind);
begin
  case AUpdateKind of
    ukModify:
    begin
      if ADataset.Locate('KeyField', 'KeyValue', []) then
      begin
        ADataset.Edit;
        ADataset.FieldByName(FirstName).AsString := PData.FirstName;
        ...
        ADataset.Post;
      end;
    end;
    ukInsert:
    begin
      ADataset.Append;
      ADataset.FieldByName(FirstName).AsString := PData.FirstName;
      ...
      ADataset.Post;
    end;
  end;
end;

When you call your edit form, pass in the Record instead of the live dataset
0
 
LVL 1

Expert Comment

by:josephsprei
ID: 33659129
If I understand correctly, your problem is, that while entering data, the table jumps away from the data you are entering, because it is inserting the data that is coming from your serial port.
If that is the case, I would suggest creating two AdoDatasets pointing to the same table, one for collecting the data from the serial port, the other for the user browse.
This way it will not have to jump back to the record the that is currently being viewed, because it will not jump away in first place......
0
 
LVL 1

Author Closing Comment

by:DigitalNam
ID: 33669742
thank you.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
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 …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

721 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