I have a table called Visitor. It can accept duplicate values. I mean the same visitor can come to the shop many times but only one time per day.
Visitor_Name | Purchase Price | Date |
---|---|---|
John | 200.00 USD | 15/12/2020 |
Bob | 150.00 USD | 15/12/2020 |
Marshall | 170.00 USD | 16/12/2020 |
I need to add a check.
If I try to add John with existing date (15/12/2020) then prevent the record insertion with a popup message "Visitor already visited the shop in that particular day".
This is the code I'm currently using.
Private Sub add()
DoCmd.RunSQL "INSERT INTO Visitor([Visitor_Name], [Purchase Price], [Date] VALUES ([Text1].Value, [Text2].Value, [Text3].Value)"
End Sub
Before adding a record I need to check the Visitor_Name value and Date value with all existing values related to that particular visitor.