Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    509

    duplicate entry flag to user

    I want something more than the usual crypic message to a user that the entry just made (into a no dups, primary key field) is a duplicate entry...
    so, I added this code... but it bounces me out...

    Private Sub txtType_BeforeUpdate(Cancel As Integer)
    If Len(Nz(Me.txtType, "")) < 1 Then 'check for an entry
    If DCount("[type]", "tbeFixtureTypeDetails", "[type]= '" & Me.Type & "'") > 0 Then 'check for an existing match
    vmsgtxt = "This fixture type is already being used; please try again"
    vmsgtitle = "DUPLICATE FIXTURE TYPE"
    Response = MsgBox(vmsgtxt, vbCritical + vbRetryCancel, vmsgtitle)
    vType = Me.txtType & "-DUP!"

    *** this next line is the one that bounces me


    Me.txtType = vType
    End If
    End If
    ...

    run-time -2147352567 (80020009)
    function set to the before... is preventing... saving the data...

    any thoughts wouldbe greatly appreciated in advance,
    Mark

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    What happens if instead of that line, this:

    Cancel = True
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    509
    that was good
    but i'm still looking for a way to re-assign a value, and that's where the error occurs
    the user will now realize that the entry is a duplicate, but re-assigning a value (from within the form) is a guessing game;

    I'd like the opportunity to replace the value with a placeholder that the user can go back and edit at a future time.. i.e. after they've exited the form and reviewed the completet set of records (the table is seldom over 50 records, so it's not such a big deal to do... and I have some tools in place that make it fairly easy) hence the code:

    vType = Me.txtType & "-DUP!"
    Me.txtType = vType

    the line: Me.txtType = ... is what's fighting me

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    txtType is textbox bound to a text field? Is '-DUP' a suffix that is saved as part of the input value?

    None of my BeforeUpdate procedures include setting the value of the control. Don't think you can. Try setting the textbox in another event, such as GotFocus:

    If IsNull(txtType) Then txtType = "-DUP"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Duplicate Entry Prevention
    By bklewis in forum Access
    Replies: 12
    Last Post: 02-26-2012, 08:02 PM
  2. Duplicate data entry on form level by user
    By Kananelo in forum Forms
    Replies: 1
    Last Post: 02-10-2012, 01:09 AM
  3. Duplicate Entry Error
    By Dee300 in forum Forms
    Replies: 3
    Last Post: 08-16-2011, 07:29 PM
  4. Prevent Duplicate Entry
    By kilosierra71 in forum Forms
    Replies: 4
    Last Post: 07-28-2011, 03:08 PM
  5. MsgBox for duplicate entry
    By usmcgrunt in forum Programming
    Replies: 3
    Last Post: 11-09-2010, 08:48 AM

Tags for this Thread

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