By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

Check & Forbid Duplicate Data in A Month

P: 14
I have a census database where I would like to forbid user insert a new census data if the same ProductID already in the database in the same month.

Thanks for your help. :D
Sep 13 '12 #1

✓ answered by Seth Schrock

Create a query that has the criteria of the current Month and the ProductID. Then, do a DCount() of that query and test the value to see if it is greater than 0 using an If/Then/Else statement. If the value is greater than 0, then set Cancel = True. This will stop the form from going to the next record and the form from closing and the data from saving. You can also create a message box telling the user what happened and what they need to do.

Share this Question
Share on Google+
2 Replies


Seth Schrock
Expert 2.5K+
P: 2,941
Create a query that has the criteria of the current Month and the ProductID. Then, do a DCount() of that query and test the value to see if it is greater than 0 using an If/Then/Else statement. If the value is greater than 0, then set Cancel = True. This will stop the form from going to the next record and the form from closing and the data from saving. You can also create a message box telling the user what happened and what they need to do.
Sep 13 '12 #2

P: 14
Thank you so much Seth... I will try your solutions. :D
Sep 13 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.