Solved

ADO Table and locate

Posted on 2010-09-12
7
710 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
  • 3
  • 3
7 Comments
 
LVL 32

Expert Comment

by:ewangoya
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:ewangoya
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

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

Accepted Solution

by:
ewangoya 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 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

22 Experts available now in Live!

Get 1:1 Help Now