wyan
asked on
How to prevent duplicate data entry in a text box??
Hi I have a simple form for data entry, the MDB file contains 4 fields, and I have a form with 4 text boxes bounded to the MDB file. My question is how do I prevent a duplicate entry on the text box??
I have a simple procedure but it gives me runtime error 3426 ??
' After entering data hit the check_duplicate button to
' check for duplicate entry
Private Sub CheckDuplicateButton_Click ()
strBookmark = ContractData.Recordset.Boo kmark
' CQuote is the textbox name which bound to the MDB file field [Quote #]
strCriterion = "[Quote #]= '" & UCase(CQuote) & "'"
ContractData.Recordset.Fin dFirst strCriterion
If ContractData.Recordset.NoM atch Then
ContractData.Recordset.Boo kmark = strBookmark
Else
MsgBox ("Duplicate Contract # Entry!!")
End If
End Sub
If I enter a quote# which previously exist it gives me runtime error 3426??
Any idea from you guys or any better way?? Oh I am using VB4.0.
Thanks
I have a simple procedure but it gives me runtime error 3426 ??
' After entering data hit the check_duplicate button to
' check for duplicate entry
Private Sub CheckDuplicateButton_Click
strBookmark = ContractData.Recordset.Boo
' CQuote is the textbox name which bound to the MDB file field [Quote #]
strCriterion = "[Quote #]= '" & UCase(CQuote) & "'"
ContractData.Recordset.Fin
If ContractData.Recordset.NoM
ContractData.Recordset.Boo
Else
MsgBox ("Duplicate Contract # Entry!!")
End If
End Sub
If I enter a quote# which previously exist it gives me runtime error 3426??
Any idea from you guys or any better way?? Oh I am using VB4.0.
Thanks
On what line do you get error 3426?
What is error 3426? (Don't have a reference next to me, sorry)
Error 3426 is "The action was canceled by an associated object."
You said in your question that you got it when you entered something that already exists.
You said in your question that you got it when you entered something that already exists.
Runtime error 3426 should have something to do with calling the update method without an edit or addnew. Are you sure you haven't made an edit earlier, and then when you move to another record and back, it is lost, and when you try update the error 3426 appears?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.