Results 1 to 7 of 7
  1. #1
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228

    "No Record Selected" after Recordset.Requery

    I have a situation where a checkbox is changing the underlying recordset. I'm using a rs.requery statement. If I go to hit the checkbox once again, without selecting a textbox or something else within the record, I receive an error for no record being selected.



    How do I refresh the recordset and then make sure the same record is the selected record after the requery?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    Can that be adapted to a recordset.requery? That method is requerying the form.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Requerying form is requerying the recordset.

    I am not familiar with Recordset Requery method.

    Post your code.
    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.

  6. #6
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    In my experience, doing a form.requery also drives this error (de-selecting all records), unless you use a form.move statement. Going this route forces a continuous form back up to the top, and it causes a visual nightmare if you're on a long list. I found that the recordset.requery does indeed refresh the data, and does the same thing the form.requery does (de-selects records). However, it doesn't force it's way to the top of the list. I.e. the cursor stays on the current record.

    Code:
    Dim rs As Recordset
    Set rs = Me.Recordset
    'currpos = rs.AbsolutePosition
    
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.RunSQL "UPDATE *********;"
    rs.Requery
    
    'rs.MoveFirst
    'rs.Move currpos
    End Sub

  7. #7
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    I actually was able to use the findfirst method without using a recordsetclone. My dataset includes an ID field, unique of course. I adjusted the code to read...

    Code:
    Dim rs As Recordset
    Set rs = Me.Recordset
    with rs
       DoCmd.RunCommand acCmdSaveRecord
    
       taskid = .fields("Task ID")
       DoCmd.RunSQL "UPDATE *********;"
    
       .Requery
       .FindFirst "[Task ID]=" & taskid
    End With
    End Sub
    Works perfect.

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

Similar Threads

  1. Suppress "Requery" and/or "Repaint" when running function
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 12-08-2017, 12:04 AM
  2. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  3. Replies: 5
    Last Post: 01-26-2015, 10:05 AM
  4. Replies: 7
    Last Post: 12-21-2014, 08:21 PM
  5. Replies: 3
    Last Post: 04-22-2013, 06:08 AM

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