Solved

ADO Table and locate

Posted on 2010-09-12
7
709 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

9 Experts available now in Live!

Get 1:1 Help Now