Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Work Order Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
RecordsetClone and Bookmark
Anne Cowden 

11 years ago
Hi Richard/Alex

I have set up a field within my WorkOrderF called OrderNumber which is indexed and set to no duplicates.

I want to prevent users from entering a duplicate number but if they do I want them to be taken to the original record.

I have the following code in the before update event:

Dim SID As String
    Dim stLinkCriteria As String
    Dim rsc As DAO.Recordset

    Set rsc = Me.RecordsetClone

    SID = Me.OrderNumber.Value
    stLinkCriteria = "OrderNumber =" & "'" & SID & "'"

    'Check WorkOrderT for duplicate OrderNumber
    If DCount("OrderNumber", "WorkOrderT", _
              stLinkCriteria) > 0 Then
        'Undo duplicate entry
        Me.Undo
        'Message box warning of duplication
        MsgBox "Order Number " _
             & SID & " Already Exists." _
             & vbCr & vbCr & "You will now be taken to that record.", _
               vbInformation, "Warning: Duplicate Information"
        'Go to record of original Order Number
        rsc.FindFirst stLinkCriteria
        Me.Bookmark = rsc.Bookmark
End If

    Set rsc = Nothing
    
End Sub

It works fine until it reaches Me.Bookmark = rsc.Bookmark

then it breaks. Can you show me what I'm doing wrong. I am using Access 2010.

Thanks
Anne


Reply from Alex Hedley:

I'm not a fan of RecordsetClone and Bookmarks

Why not set it to:
Set rsc = CurrentDb.OpenRecordset("TABLE/QUERY", dbOpenDynaset)

Or you could say
Set rsc = Me.Recordset.Clone

Also it might not be the Bookmark that is the issue, sometimes Access highlights the next line.
Is OrderNumber a String or Integer
stLinkCriteria = "OrderNumber =" & "'" & SID & "'"
If Integer change to:
stLinkCriteria = "OrderNumber=" & SID

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Work Order Lessons.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/17/2026 2:04:34 AM. PLT: 1s