Programming for Everybody: insert button without duplicate values
Showing posts with label insert button without duplicate values. Show all posts
Showing posts with label insert button without duplicate values. Show all posts

Very simple Code insert button VBA without duplicate values in MS Access VBA with source code





Source Code in video

Dim dbs As DAO.Database

Dim rst As DAO.Recordset

Dim strsql As String

Set dbs = OpenDatabase("H:\products.accdb")

Set rst = dbs.OpenRecordset("Select product From Table1 Where product = '" & Me.Text0.Value & "' ")

If rst.RecordCount > 0 Then

MsgBox ("This Product exists before")

Else

strsql = "Insert Into Table1(product)Values( '" & Me.Text0.Value & "' )"

dbs.Execute (strsql)

MsgBox ("The product inserted successfully")

End If

rst.Close

dbs.Close