Solved

Duplicate Value Check in cxGrid!

Posted on 2006-11-28
7
1,118 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
  • 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
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.

 

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

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

862 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

24 Experts available now in Live!

Get 1:1 Help Now