Message showing duplicate policy number

A

Alex Martinez

Hello,

I have have a claims database log. In the form I like the user to be
notifiy if he inputted the same policy number already in the database. He
can continue inputing the same policy number and populate the fields, but I
just want him to know this. If the user inputs a new policy number which is
already in the database I like to have a simple pop-message saying that
"There is a policy number that has been entered before" Any tips will be
appreciated. Thank you in advance.
 
G

Graham Mandeno

Hi Alex

You can use the DCount function to check for the existence of records
matching certain criteria:

If DCount( "*", "[YourTable]", "[PolicyNum]=" & Me.PolicyNum ) <> 0 Then

If PolicyNum is a text field then you must enclose the value in quotes:
"[PolicyNum]='" & Me.PolicyNum & "'"

I suggest you put this check in the BeforeUpdate event proc for PolicyNum.
that way you can use a MsgBox to ask the user if he wants to continue and,
if not, cancel the event.
 
A

Alex Martinez

Graham,
Thanks for the tip I appreciate your help.
Cheers

Graham Mandeno said:
Hi Alex

You can use the DCount function to check for the existence of records
matching certain criteria:

If DCount( "*", "[YourTable]", "[PolicyNum]=" & Me.PolicyNum ) <> 0 Then

If PolicyNum is a text field then you must enclose the value in quotes:
"[PolicyNum]='" & Me.PolicyNum & "'"

I suggest you put this check in the BeforeUpdate event proc for PolicyNum.
that way you can use a MsgBox to ask the user if he wants to continue and,
if not, cancel the event.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Alex Martinez said:
Hello,

I have have a claims database log. In the form I like the user to be
notifiy if he inputted the same policy number already in the database.
He can continue inputing the same policy number and populate the fields,
but I just want him to know this. If the user inputs a new policy number
which is already in the database I like to have a simple pop-message
saying that "There is a policy number that has been entered before" Any
tips will be appreciated. Thank you in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top