Private Sub txtLastName_BeforeUpdate(Cancel As Integer)
Dim mResponse As Integer
Dim mySql As String
Dim sWhere As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim tbx As String
tbx = (Me.txtLastName)
mySql = "SELECT myTBL.LastName FROM myTBL "
sWhere = "WHERE myTBL.LastName = " & tbx
mySql = mySql & sWhere
Set db = CurrentDb
Set qdf = db.QueryDefs("qryProject")
qdf.SQL = mySql
qdf.Close
If (Me.txtLastName) = [myTBL.LastName] Then
mResponse = MsgBox("Duplicate Entries Detected!", vbYesNo)
If mResponse = vbYes Then
DoCmd.OpenQuery "qryProject", acViewNormal
Else
Exit Sub
End If
End If
End Sub
|