Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using methods in textbox of grid

Status
Not open for further replies.

waleedq

Programmer
Apr 20, 2009
1
PK
I have used a grid control. Now I want to check duplicate entry in one column. I have written code to check duplication in valid event of the textbox of that column but it is not working. Needs help, thanks in advance.

 
What is the recordsource of your grid?
If it is a table or a cursor, check for duplicates in the recordsource instead.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
What is your code? Something like this would work:
Code:
local array arrExists[1]
local luKey,luValue
luKey = myTable.myKeyColumn
luValue = this.Value
select count(*) ;
from myTable (with buffering=.t.) ;
where myColumn == m.luValue and myKeyColumn <> m.luKey ;
into array arrExists
if arrExists > 0
  * dupe
endif

PS: Use lostfocus rather than valid. You can add:

NoDefault
this.Setfocus

to keep focus there if it is not valid, using valid in a grid column is not a good idea IMHO.

Cetin Basoz
MS Foxpro MVP, MCP
 
"but it is not working"

How do you know it is not working?
* Does it appear to not be executing?
* Is it executing, but not finding duplicates?
* Is it throwing an error message?
* What?

Have you put a SET STEP ON in your code within the textbox Valid method to actually watch it execute line-by-line?

If you have done so, then you would know where and/or how it was not working.

If you have not done so, then I'd recommend that you do so now and examine the cdoe as it executes to find out what it wrong.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top