Solved

Duplicate Value Check in cxGrid!

Posted on 2006-11-28
7
1,156 Views
Last Modified: 2011-09-20
Dear Sir,
  My name is Daniel, from Taiwan. I have a little problem and need for your assists!
  How to check the data in cxGrid are all unique during data input?
  I was using TDBGrid before and did the check like this:

  procedure TDataModuleLcEntry1.QueryLc12ORDNOChange(Sender: TField);
  begin
    if CheckDup(QueryLc12ORDNO.AsString) then
    begin
      // go further
    end
    else
    begin
      ShowMessage('ORDER NO. Duplicate, Please input again!');
    end;
  end;

  function TDataModuleLcEntry1.CheckDup(myOrd: string): boolean;
  var
    V: Variant;
  begin
    V := QueryLc12.Lookup('ORDNO', myOrd, 'ORDNO');
    Result := (VarType(V) in [varNull]);
  end;

  This dosen't work with cxGrid, the ORDNO Column in cxGrid will all became the value as myOrd! don't know why!
  My English is not very well, hope you can understand what I am asking! Thanks for your help!
 
  Daniel
0
Comment
Question by:daniel710624
[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
  • 2
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 18043683
maybe you could use a secondary query instead the lookup-method? possible for you?

meikl ;-)
0
 

Author Comment

by:daniel710624
ID: 18052046
Thanks for your help! But I can't use secondary query to instead, because of data haven't applied to database!
User can input many rows of data, than execute ApplyUpdates! Secondary query can't be my choice!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 18052071
in case of cachedupdates u cannot use a secondary query, thats true

thinking . . .
0
Independent Software Vendors: 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!

 

Author Comment

by:daniel710624
ID: 18135622
Still waiting for help! Thanks!
0
 

Author Comment

by:daniel710624
ID: 19271767
I found a way, but don't know if there is any better way?
Any one could help me out with this?

procedure TFormBaseGridEntry1.CheckKeyDup(KeyCol: word; Key1, Key1Label: String);
var
  i, x: Integer;
begin
  x := cxGridMasterView1.DataController.FocusedRowIndex;
  for i := 0 to cxGridMasterView1.viewdata.RowCount - 1 do
  begin
    if cxGridMasterView1.ViewData.Rows[i].Index = x then Continue;
    if Trim(cxGridMasterView1.ViewData.Rows[i].Values[KeyCol]) = Key1 then
    begin
      RepeatWarning(Key1Label);
      cxGridMasterView1.Controller.FocusedItemIndex := KeyCol;
      Abort;
    end;
  end;
end;
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21135793
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

696 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