'-- Skip the current recordIF Me.Count > 0 Then lnPK = Me.PrimaryKeyFieldElse lnPK = -1End If
'-- Build the command textloCommand.CommandText = "SELECT COUNT(*) FROM MyTable WHERE MyPrimaryKeyField != @MyPrimaryKeyField And MyTestField = @MyTestField"
'-- Create the parmsloCommand.Parameters.Add("@MyPrimaryKeyField",SqlDataType.Int)loCommand.Parameters.Add("@MyTestField",SqlDataType.VarChar)
'-- Set the parmsloCommand.Parameters("@MyPrimaryKeyField").Value = lnPKloCommand.Parameters("@MyTestField").Value = MyPassedTestValue
'-- Return the resultsReturn CType(Me.ExecuteScalar(loCommand), Integer)End Sub