How to Use RecordsetClone in Microsoft Access

Sdílet
Vložit
  • čas přidán 11. 09. 2024
  • In this episode, we take a look at the RecordsetClone feature in MS Access that allows us to not only look up information on continuous forms that the user works on, but also allows us to force navigation on those forms to our record of choice, based on some context.
    Block spammers from harassing your Remote Desktop, filling your Windows security logs with failed RDP attempts, and burning up your bandwidth with my BZ RDP Cloaker:
    buy.billzone.c...
    Check out my easy time entry system for your business:
    system.billzon...
    Join me on Patreon!
    / mackenziedataengineering
    Check out some tech (and support my channel!):
    www.amazon.ca/...
    Want the code from this video?
    mackenziemacken...
    Interested in transforming your career or finding your next gig?
    system.billzon...
    Want my team to do a project for you? Let's get to it!
    system.billzon...
    Contact form you can find at www.mackenziema...
    Follow me on social media:
    / mackenziedataanalytics
    / seamacke
    / seamacke
    / seamacke
    / psmackenzie
    Get Microsoft Office including Access:
    click.linksyne...
    Got a CZcams Channel? I use TubeBuddy, it is awesome. Give it a try:
    www.tubebuddy....
    #msaccess #vba

Komentáře • 15

  • @jamesmartinez9069
    @jamesmartinez9069 Před 4 měsíci +1

    Ingeniero Sean, Lo felicito, la sencillez de su explicación es fabulosa, así como su generosidad al compartir sus conocimientos. Dios lo bendice. Un saludo desde Colombia

  • @hassanrozh6579
    @hassanrozh6579 Před 4 měsíci +1

    Great job, thanks so much.

  • @simonmaersk
    @simonmaersk Před 4 měsíci +1

    Great video. Tahnk you! Can this be used to make "pages" on a long continuous form? Like for example, if I have a form with a lot of records that I want to show only 50 records at a time, and then have "Next" and "Previous" buttons to go to the next or previous 50 records in the recordset? If so, how would you go about it?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Před 4 měsíci

      I suppose you could have your subform loaded and when the user clicks next 50 as you suggest, just use the recordsetclone to scroll forward from the starting point of 0, get the bookmark, set the subform's recordset bookmark to the recordsetclone's. Have some marker fields that say "you are now viewing 51 to 100. The user looks at some records there, then clicks Next, the program gets 100 from the marker, scrolls forward 100 + 50 from a recordsetclone, sets the bookmarks again, etc. I think it is worth a try! You would have to account for when the user scrolls past the end of 50 (or to previous records) on their own and maybe auto-set the paging after detecting it. Something like that. Cool idea!

    • @simonmaersk
      @simonmaersk Před 4 měsíci

      @@seanmackenziedataengineering Thank you for your reply! A video on this would be awesome 😉

  • @zoomingby
    @zoomingby Před 4 měsíci

    5:15 thanks for this! Question, why were you able to just use dim rsc As DAO.recordset without also having to create the Dim db as DAO.Database command? Can you leave that command out as given whenever you want to work in the current database?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Před 4 měsíci

      Great question. In almost all contexts you can leave off "DAO." from the database object and it will default to DAO and you don't have to worry about it. You can add it to both Database and RecordSet to be more specific and it will work just fine. In some (rare by my experience) contexts, you DO need to add it to the Database object or it will not compile. Generally this is related either reference and/or MS Access version. RecordSet could point to either an ADODB recordset (most common in the VB6 world but often used in Access too) or a DAO recordset (most common in the Access world and rarely in the VB6 world). ADODB does not generally use the Database object in VBA since you use the Connection object instead to get your Recordset.

  • @daveyks1
    @daveyks1 Před 4 měsíci +1

    I've tried using database clone...but it doesn't recognize the command. Any thoughts? I've checked all my libraries and I beileve they all load fine?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Před 4 měsíci

      Interesting.. I would make sure that you make sure to reference DAO.Recordset in your dim statement and not just Recordset. Also, try a Debug > Compile as sometimes it might be fine but Intellisense did not recognize it (but it will run). If you don't get an error on Compile, it might be fine.

  • @rtatt1
    @rtatt1 Před 4 měsíci +1

    Nice video. But can you give a working example of when you should use a form's RecordsetClone property rather than the Clone method of the form's Recordset and vice versa?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Před 4 měsíci +1

      One example is that a RecordsetClone is always read-only, whereas the Clone method can be used to create one or more RecordSets that might not be read-only. You don't want to trigger a lock conflict by navigating and updating the same data via several Clones (plus the open form!).