Duplicating Data in Text Box

G Marshall

Board Regular
Joined
Dec 31, 2002
Messages
134
Hello

I have an input form linked to a table. On the form I have a text box for the user to enter a "Scheme Code Number" e.g W355. It is o.k for the user to duplicate this number in the table but if the user enters a number that has already been used I would like a message to appear on screen advising that the number has already been used with the option of entering o.k to continue or no to return to the text box.
If o.k has been clicked then I would need the cursor to move to the next text box on the form.
I realise that this would be an "on input" event procedure but I have no idea how to code the request.
Appreciate any help


Gerald
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Add some code to the Before Update event of the Text Box. Something like this.

If DCount("[PrimaryKey]", "TableName", "[PrimaryKey]= '" & Me![TextBoxName] & "'") = 1 Then
MsgBox "The number you have entered is a duplicate"
Me.Undo
Cancel = True
End If
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,791
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top