Probably you will have to check for Unique_Id too, as far as I understand this, it can have different names for single Unique_Id. If that is right, then your query should look something like this.
sql = "Select Name from Table where Unique_Id = " & UniqueId_Var & " and Name ='" &txtname& "'"
Else it will not let you add "xyz" as NAME again for another Unique_Id.
Hope that helps.
- Vijay G
Strive for Perfection