something like this. Note this is not a VBA Code but VB6 you may have to make some adjustments to the syntax![]()
Code:Private Sub cmdSave_Click() 'conn is ADODB.Connection 'rsTemp is ADODB.Recordset Dim SQLtemp As String Dim bNameExists As Boolean bNameExists = True SQLtemp = "SELECT COUNT (*) FROM YOURTABLE WHERE NAME_OF_PERSON = '" & Me.Text1.Text & "'" Set rsTemp = conn.Execute(SQLtemp) If rsTemp.Fields(0).Value > 0 Then bNameExists = False End If If bNameExists = True Then MsgBox "Duplicate Entry" Exit Sub Else 'continue with saving End If End Sub




Reply With Quote