Results 1 to 3 of 3
  1. #1
    adams77 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    16

    Updating Recordset with VBA Code

    I am trying to update tblPending with Send (Y/N) , if it is Yes then update to No. Do I need to use True / False?

    Thanks for your help.
    [Private Sub Report_Close()
    'Closed Event is processed last


    'This procedure in table pending will remove yes in send

    On Error GoTo ErrorHandler
    Dim sql As String
    Dim rs As ADODB.Recordset
    sql = "SELECT * FROM tblPending WHERE Send = Yes"
    Set rs = New ADODB.Recordset
    rs.Open sql, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    With rs
    If Not .BOF And Not .EOF Then
    .MoveLast
    .MoveFirst
    If .Supports(adUpdate) Then
    Do Until .EOF
    ![Send] = "No" & ![Send]
    .Update
    .MoveNext
    Loop
    End If
    End If
    .Close
    End With
    ExitSub:
    Set rs = Nothing
    Exit Sub
    ErrorHandler:
    Resume ExitSub

    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    You dont need ANY code for this.
    just run 1 update query that does makes the change.
    Zero code.

  3. #3
    adams77 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    16
    Thank you!!!!

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

Similar Threads

  1. Replies: 4
    Last Post: 01-22-2015, 09:57 AM
  2. Replies: 6
    Last Post: 03-26-2014, 10:04 AM
  3. Recordset loop not updating and breaks
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 02-24-2014, 05:33 PM
  4. RecordSet Clone Problem with code
    By rlsublime in forum Programming
    Replies: 8
    Last Post: 06-21-2012, 11:56 AM
  5. Replies: 1
    Last Post: 04-04-2012, 05:11 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