?
Solved

Duplicate rows in dbgrid

Posted on 2000-04-16
4
Medium Priority
?
537 Views
Last Modified: 2010-04-04
Hello all ...

How does one check if a row to be
added to a dbgrid - already exists - before adding it?

I am not posting any values to the database until I press a certain button ... so all the rows are not yet saved when I want to run this check.

Thanx,
Fats
0
Comment
Question by:ffelaar
[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
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2720293
You can check it directly in your table for example:

if Table1.Locate('Name', Edit1.Text, [loCaseInsensitive]) then
 ...// that means it is already exists

Motaz
0
 

Author Comment

by:ffelaar
ID: 2720335
Wont this way always return false? There really are no records in the dataset yet ... which, by the way, is a tquery selecting from multiple tables and which has cachedupdates enabled.

Fats
0
 
LVL 4

Accepted Solution

by:
Radler earned 150 total points
ID: 2727357
procedure AddField( AField : TField );
for i:=0 to grid.Columns.Items-1 do begin
  grid.Columns.Items[i].FieldName = Afield.FieldName then begin
    //Skip add action
  end else begin
   //Add the field
  end;
end;

T++, Radler
0
 

Author Comment

by:ffelaar
ID: 2792112
I have used a variation of your comment. It put me in the right direction.

Thank you Radler
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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
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
Course of the Month10 days, 8 hours left to enroll

765 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