ok i finally tried and got it as desired but only one point is left. It does not highlight only the duplicate fields instead it highlights all the rows of MSFlexGrid.
Could anyone correct me as to what is going wrong? Here is the modified code:
'open Item table
Set myrs2 = New ADODB.Recordset
myrs2.Open "Item", mycon, adOpenKeyset, adLockPessimistic, adCmdTable
'verify item numer for duplicate entry
Dim z As Integer
For z = 1 To MSFlexGrid1.Rows - 1
If MSFlexGrid1.TextMatrix(z, 0) = myrs2.Fields("ItemNumber") Then
MsgBox "Duplicate Item Number(s) found! Please edit or remove the corresponding Item details.", vbOKOnly + vbCritical, "Duplicate Entry"
Dim y%, x%
For x = 1 To .Rows - 1
For y = 1 To .Cols - 1
.Row = x
.Col = y
.CellBackColor = vbRed