Hello, I am having trouble with the syntax for a DCount function for an If then Statement to prevent duplicate data.
I have searched the forum and the web but the more I look, the more confused I get. :banghead: However I am a lot closer.....
I have a text box on a form to input a text value. I want to write a macro that will use the Dcount function to check for duplicate records when the text box loses focus or before change event.
I do have “no duplicates” at the table level but I want to catch it right away to alert the user.
This is what I have in my If Then Statement but I can’t seem to get it correct.
Dcount(“*”,”tblSession”,”[SessionID]=’ & [Forms]![frmSession]![Sessionid]’”)>0
I think my issue is in my criteria section. Any help is appreciated. Thank you in advance.
I have searched the forum and the web but the more I look, the more confused I get. :banghead: However I am a lot closer.....
I have a text box on a form to input a text value. I want to write a macro that will use the Dcount function to check for duplicate records when the text box loses focus or before change event.
I do have “no duplicates” at the table level but I want to catch it right away to alert the user.
This is what I have in my If Then Statement but I can’t seem to get it correct.
Dcount(“*”,”tblSession”,”[SessionID]=’ & [Forms]![frmSession]![Sessionid]’”)>0
I think my issue is in my criteria section. Any help is appreciated. Thank you in advance.