This is my first post and vba is something I dabble in so please excuse my ignorance.
I have a form which is to allow duplicate entries. Dups are defined as having the same pnbr and hic. I would like to provide the user with a message indicating which records are dups. I started by creating a table with the dups but I don't know how to get the values in the table into a message. If there's a better way, please let me know.
I have a form which is to allow duplicate entries. Dups are defined as having the same pnbr and hic. I would like to provide the user with a message indicating which records are dups. I started by creating a table with the dups but I don't know how to get the values in the table into a message. If there's a better way, please let me know.
Code:
Private Sub HIC_Exit(Cancel As Integer)
Const newTableName = "Tbl_Temp"
Dim db As Database
Dim strSql As String
' SQL string to create a new table
strSql = "SELECT ID "
strSql = strSql & "INTO [" & newTableName & "] "
strSql = strSql & "FROM [Tbl_Entry]"
strSql = strSql & " WHERE PNBR = '" & Me.PNBR & "'" & " AND HIC = '" & Me.HIC & "'"
On Error Resume Next ' Delete table if it exists
DoCmd.DeleteObject acTable, "Tbl_Temp"
DoCmd.SetWarnings False
DoCmd.RunSQL strSql
DoCmd.SetWarnings True
db.Close
End Sub