[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to prevent duplicate data entry in a text box??

Posted on 1997-05-15
5
Medium Priority
?
205 Views
Last Modified: 2012-06-27
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.Bookmark
    ' CQuote is the textbox name which bound to the MDB file field [Quote #]
    strCriterion = "[Quote #]= '" & UCase(CQuote) & "'"

    ContractData.Recordset.FindFirst strCriterion
    If ContractData.Recordset.NoMatch Then
        ContractData.Recordset.Bookmark = 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
0
Comment
Question by:wyan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 5

Expert Comment

by:y96andha
ID: 1426324
On what line do you get error 3426?
0
 
LVL 2

Expert Comment

by:vorlon
ID: 1426325
What is error 3426? (Don't have a reference next to me, sorry)
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1426326
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.
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1426327
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?
0
 

Accepted Solution

by:
mikekr earned 100 total points
ID: 1426328
I don't know what an error 3426 is, but the easiest way to prevent dupilcate data is to set the index property of each field in the table to Yes(No Duplicates)... If your text fields on the form are bound to a data contol, when the data control updates the data in the table, and error will be returned... I can't remember the error number, but I'm sure you'll be able to work it out. You can then trap the error at run time, and use code to deal with the error.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question