Results 1 to 7 of 7
  1. #1
    forumer is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2014
    Posts
    9

    Duplicate Record Error Message!!

    Can anyone please help me as to how to make a user-friendly message when a duplicate record entered into database?

    I couldn't customize the database duplicate error message and also tried to do it within the form but no success so far!

    I would be extremly grateful for any help



    Thank you.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    What Field(s) constitute a 'duplicate' Record? What are Datatypes of the Field(s)?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    forumer is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2014
    Posts
    9
    Hi MissingLinq,

    Thank you for your reply. I want to change the databse msg when duplicates being entered into stNo in RegisterStudent form. How can I change the msg to a meaningful one or how can I antisipate for this error in the form? You can downlload the database from this link http://www.filefactory.com/file/1pvl...n/RegSys.accdb


    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    Personally, I would do validation on the input and prevent the error.

    Why would a duplication occur? What is your business process that allows this?
    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.

  5. #5
    forumer is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2014
    Posts
    9
    Hi June,

    Thanks for the reply. I want to stop the user from entering a duplicate student no in RegisterStudent form. How can I do that? What type of event should I choose and should it be at control level or at form level?

    I wrote this but the trouble is that it clears all the form instead of just the stNo control! and when I used me.stNo.undo , the system message of duplicated shows instead of mine which means it tries to save the record while I want to stop the save action all together!

    Private Sub stNo_AfterUpdate()
    If DCount("[stNo]", "student", "[stNo] = '" & Me.stNo & "'") > 0 Then
    MsgBox "The student No has been entered into the dtabase before. No duplicates allowed!", , "Error Message"
    Me.Undo
    Me.stNo.SetFocus
    End If
    End Sub

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    stNo is control?
    Try BeforeUpdate event of stNo.
    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.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As June said, the stNo_BeforeUpdate would be the place for this code; this keeps the keeps the duplicate from being committed and keeps focus on the Control, something that can't be done from the AfterUpdate event by simply using Me.stNo.SetFocus.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 4
    Last Post: 01-14-2016, 02:18 PM
  2. Replies: 1
    Last Post: 11-21-2013, 12:17 PM
  3. Replies: 15
    Last Post: 11-01-2013, 03:24 PM
  4. Customise the duplicate values error message
    By lsmcal1984 in forum Forms
    Replies: 2
    Last Post: 10-09-2013, 04:36 PM
  5. Replies: 13
    Last Post: 12-31-2012, 10:41 PM

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