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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To check duplicate row in datawindow 1

Status
Not open for further replies.

jancypaul

Programmer
Aug 3, 2007
20
GB
Dear all

Please give me a tips to check the existance of duplicate rows using more than one column in datawindow while before going to update

Regards

 
dear jan
u can validate this at the itemchanged event of that columns which u want to check duplicate.
 
Or you can go even more old-fashioned and loop through your columns (and rows if need be) and check the values against each other.
 
Here a suggestion:

//=>Local control.
Long ll_existe
ll_existe = This.Find("your_code = '" + is_saisie + "'", 1, This.RowCount())
If ll_existe > 0 Then
MessageBox('Local Duplicate','Your Message.',StopSign!,OK!)
Return 1
End If

Hope it can help you.

SugarRc
 
//====================================================================
// Event: wfc_n_cst_dwsrv.of_isunique()
//--------------------------------------------------------------------
// Desc: CHECK IF the passed Array is unique in the datawindow
//--------------------------------------------------------------------
// Args:
// value string as_cols[]
//--------------------------------------------------------------------
// RETURN: boolean
// TRUE
// FALSE
//--------------------------------------------------------------------
// Author: LiXG Date: 2007.07.16
//--------------------------------------------------------------------
//
//--------------------------------------------------------------------

Long ll_i,ll_rowcount
Long ll_j,ll_upperbound
String ls_Temp1,ls_Filter
String ls_Temp2,ls_Sort
String ls_Text,ls_Msg
Boolean lb_State

//??Temp Data
ll_rowcount = idw_Requestor.Rowcount()
DataStore lds_Temp
lds_Temp = Create DataStore
lds_Temp.Dataobject = idw_Requestor.Dataobject
lds_Temp.Settransobject(SQLCA)
IF idw_Requestor.Rowscopy(1,ll_rowcount,Primary!,lds_Temp,lds_Temp.Rowcount()+1,Primary!) = -1 THEN RETURN TRUE

//??Build SORT?FILTER
ll_upperbound = Upperbound(as_cols[])
FOR ll_j = 1 To ll_upperbound
//Filter
ls_Temp1 = "("+as_cols[ll_j] + " = " + as_cols[ll_j] + "[-1] )"
IF ll_j = 1 THEN
ls_Filter = ls_Temp1
ELSE
ls_Filter = ls_Filter+" AND "+ls_Temp1
END IF

//Sort
ls_Temp2 = as_cols[ll_j]+" A "
IF ll_j = 1 THEN
ls_Sort = ls_Temp2
ELSE
ls_Sort = ls_Sort + " ,"+ls_Temp2
END IF

//get the col title
ls_Text = idw_Requestor.Describe(as_cols[ll_j]+"_t.Text")
IF ll_j = 1 THEN
ls_Msg = ls_Text
ELSE
ls_Msg = ls_Msg + ","+ls_Text
END IF
NEXT
IF Trim(ls_Filter) <>'' THEN
ls_Filter = '(NOT '+ls_Filter+") or getrow()=1"
END IF

//??Sort and Filter ,if there is still have data after filter,it is not unique
lds_Temp.Setsort(ls_Sort)
lds_Temp.Sort()
lds_Temp.Setfilter(ls_Filter)
lds_Temp.Filter()
IF lds_Temp.Rowcount() < ll_rowcount THEN
// Messagebox("", + '['+ls_Msg+"]There is not unique!",StopSign!)
as_Error = '['+ls_Msg+"]is not unique!"
RETURN FALSE
END IF

RETURN TRUE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top