Results 1 to 3 of 3
  1. #1
    eseng is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    3

    Improving Double entry prevention

    Hi, this is the vba code that I am using to prevent double entry. It actually works well. Unfortunately, there is still one problem, take a look in my example:



    Recorded entry: Jhon's Laundry Shop
    New entry: Jhon's laundry Shop

    In this case, Access accepts the NEW entry if I make changes (uppercase to lowercase) vise versa in the name of the entry. How can we improve the code to prevent this from happening?

    Dim NewBusinessName As String
    Dim stlinkcriteria As String


    NewBusinessName = Me.BusinessName.Value
    stlinkcriteria = "[BusinessName] = " & Chr(34) & NewBusinessName & Chr(34)
    If Me.BusinessName = DLookup("[BusinessName]", "Sheet1", stlinkcriteria) Then
    MsgBox "" & NewBusinessName & " is already in the Database." _
    & vbCr & vbCr & "Data Entry Denied!!!", vbInformation, "DUPLICATE ENTRY"
    Me.Undo 'undo the process and clear all fields

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    There are a few different things.
    Convert the strings to all upper or lowercase for the comparison. (ie. Ucase() or LCase())
    Use strComp() and do a case insensitive comparison.

    You'll still have a problem with misspelled words ie. Jhon's and John's for instance.

    I usually do several comparisons and then present the user with a list of matches to determine if its a duplicate or not. Usually a good idea to compare more than just the name as there maybe legit dupes.
    For instance with people I compare the names and also DOB or address. I also check for minor misspellings with levenschtein distance.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Are you using Option Compare Binary in your modules? It's the only reason I can think of that would allow multiple variations of data just because they're not the same case. Why not just set the table field to not allow dupes? No idea if that would work if you're using Option Compare Binary though.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Double Booking Prevention?
    By Maths9876 in forum Access
    Replies: 2
    Last Post: 12-27-2016, 08:41 PM
  2. Double Data Entry Forms
    By huongdl1987 in forum Programming
    Replies: 3
    Last Post: 09-14-2013, 01:57 AM
  3. Double Entry System
    By mkc80 in forum Access
    Replies: 3
    Last Post: 04-27-2012, 03:53 PM
  4. Duplicate Entry Prevention
    By bklewis in forum Access
    Replies: 12
    Last Post: 02-26-2012, 08:02 PM
  5. Building double data entry database
    By Hyunjee in forum Programming
    Replies: 5
    Last Post: 12-13-2011, 10:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums