Solved

ADO Table and locate

Posted on 2010-09-12
7
726 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
Industry Leaders: 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!

 
LVL 1

Author Comment

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

Accepted Solution

by:
Ephraim Wangoya earned 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month7 days, 15 hours left to enroll

617 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