Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT [Visrep], [Drgsplno] FROM MAINDB WHERE weld = """ & weld & """ AND Drgsplno = """ & Drgsplno & """ AND [ID] <> " & ID)
'If weld is a string add as ..Weld = """ & txtNewWeld & """")
If rs.EOF <> True Then
MsgBox "Weld already exists." & vbCrLf & vbCrLf & "Drawing No = " & rs.Fields("Drgsplno") & vbCrLf & "Report No = " & rs.Fields("Visrep")
weld.Undo
End If
rs.Close
db.Close
|