Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 52
  1. #16
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    Quote Originally Posted by RuralGuy View Post
    So you do not want the single quotes:
    Code:
    Private Sub PostNumber_AfterUpdate()
       Dim SID As String
       Dim stLinkCriteria As String
       Dim rsc As DAO.Recordset
       Set rsc = Me.RecordsetClone
       SID = Me.PostNumber
       stLinkCriteria = "[PostNumber]=" & SID
       'Check Employee Table table for duplicate
       If DCount("PostNumber", "Employee Table", stLinkCriteria) > 0 Then
          'Undo duplicate entry
          Me.Undo
          'Message box warning of duplication
          MsgBox "Warning Post Number " _
                 & SID & " has already been entered." _
                 & vbCr & vbCr & "You will now been taken to the record.", _
                 vbInformation, "Duplicate Information"
          'Go to record of original record
          rsc.FindFirst stLinkCriteria
          Me.Bookmark = rsc.Bookmark
       End If
       Set rsc = Nothing
       
    End Sub

    i still get the error my friends...is it possible that the error can be somewhere before the Post Number???

  2. #17
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    What error are you getting?

  3. #18
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    Quote Originally Posted by RuralGuy View Post
    What error are you getting?

    "Dublicate Information" Warning Post Number 11 has already been entered. You Will now been taken to the record. i get this even if a change 100 numbers.

  4. #19
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Hmm...any chance you can post the db or at least enough of it for me to play with?

  5. #20
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    Quote Originally Posted by RuralGuy View Post
    Hmm...any chance you can post the db or at least enough of it for me to play with?

    ok i try n do that tomorrow am off to bed now my friend, thanks for your help.

  6. #21
    thhui is offline Competent Performer
    Windows XP Access 2002 (version 10.0)
    Join Date
    Feb 2009
    Posts
    235
    Try my code instead:-
    Still use the beforeupdate event
    The logic of original code is ok.
    I have seen a few similar examples before.
    The change is highlighted for easy reference.

    Code:
    Private Sub PostNumber_BeforeUpdate(Cancel As Integer)
     
       Dim SID As Long
       Dim stLinkCriteria As String
       Dim rsc As DAO.Recordset
       Set rsc = Me.RecordsetClone
       SID = Me.PostNumber
       stLinkCriteria = "[PostNumber]=" & SID
       'Check Employee Table table for duplicate
       If DCount("PostNumber", "Employee Table", stLinkCriteria) > 0 Then
          'Undo duplicate entry
          Cancel = True
          Me.Undo
          'Message box warning of duplication
          MsgBox "Warning Post Number " _
                 & SID & " has already been entered." _
                 & vbCr & vbCr & "You will now be taken to the original record.", _
                 vbInformation, "Duplicate Information"
          'Go to record of original record
          rsc.FindFirst stLinkCriteria
          Me.Bookmark = rsc.Bookmark
       End If
       Set rsc = Nothing
    End Sub

  7. #22
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    i still get the error even if i change it the way u told me.

    if u guys dnt mind pm you mail addss and i will send u my DB its about 1.5Mb

    thanks

  8. #23
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You can zip it up and attach it to a post here. Just scroll down to Manage Attachments.

  9. #24
    thhui is offline Competent Performer
    Windows XP Access 2002 (version 10.0)
    Join Date
    Feb 2009
    Posts
    235
    Pls upload the file in access 2000 format

    I've tried my code in my access db and it works as expected.

    By the way, Have you enabled DAO by reference?

  10. #25
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    Quote Originally Posted by RuralGuy View Post
    You can zip it up and attach it to a post here. Just scroll down to Manage Attachments.

    i tried to do that earlier while i was @ work it didn't work i will try again am home nw.

    i know the database must be a mess...but just remember i am new to it...lol.

  11. #26
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Try attaching the db directly. The zip you posted is not valid. This forum can handle up to a 2MB file.

  12. #27
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    Quote Originally Posted by RuralGuy View Post
    Try attaching the db directly. This zip is not valid. THis form can handle up to a 2MB file.

    i change the file extension to from *.accdb to mdb so i can upload it.

    hope it work now.

  13. #28
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    sorry here it is...

  14. #29
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    I do not see a PostNumber control anywhere on the form nor any of the code we have been discussing.

  15. #30
    islandboy is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    63
    Quote Originally Posted by RuralGuy View Post
    I do not see a PostNumber control anywhere on the form nor any of the code we have been discussing.

    when u open the DB you dnt see the post number filed? under employee tab?

Page 2 of 4 FirstFirst 1234 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. If duplicate record, go to original record
    By BigBear in forum Forms
    Replies: 2
    Last Post: 10-06-2010, 02:58 AM
  2. Duplicate record failure
    By bugchaser in forum Access
    Replies: 5
    Last Post: 05-21-2009, 08:38 AM
  3. Replies: 0
    Last Post: 01-06-2009, 02:17 PM
  4. Deleting Record Contents, not complete record...
    By Charles Waters in forum Access
    Replies: 2
    Last Post: 06-24-2008, 12:00 PM
  5. i need record dividers
    By dunston in forum Reports
    Replies: 1
    Last Post: 11-11-2006, 07:57 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