Results 1 to 5 of 5
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Recordset not behaving as expected

    So I have the below code and when it runs instead of rs getting one record ("Streamlined Communications - Automated") It appears the RS is getting everything in the table. When I ran the first "Do While" loop it updated the very last record in the table which was "Forecast Accuracy"...

    Code:
        vMetricName = "Streamlined Communications - Automated"
        mySQL = "SELECT * FROM RAW_Data WHERE [MetricName] = '" & vMetricName & "';"
        Set rs = db.OpenRecordset(mySQL, dbOpenDynaset)
        rs.MoveLast
        rs.MoveFirst
    
        i = 0
        Do While Not rs.EOF
            For Each fld In rs.Fields
                i = i + 1
                If IsNull(fld.Value) Then
                    rs1.Edit
                    rs1("FiscMonth" & i).Value = vPctAuto
                    rs1.Update
                    rs.MoveLast
                    Exit For
                End If
            Next fld
        rs.MoveNext
        Loop


  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Nevermind....

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Care to share your discovery with others that read this forum so they could learn?

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    It was a rather simple, stupid mistake. If you notice in my edits I was using rs1 to edit the field. rs1 was not based on a SQL statement, it was loading the entire table. I changed rs1 to rs in all instances and it works perfectly now.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks! Others will appreciate the update.

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

Similar Threads

  1. Syntax Error while calling sub: Expected: =
    By cowboy in forum Programming
    Replies: 3
    Last Post: 07-12-2010, 02:21 PM
  2. intellisense not behaving
    By avianrand in forum Programming
    Replies: 3
    Last Post: 06-18-2010, 04:59 PM
  3. Replies: 1
    Last Post: 11-13-2009, 03:03 AM
  4. Too few parameters. Expected 2.
    By PPCMIS2009 in forum Access
    Replies: 0
    Last Post: 01-28-2009, 01:02 PM
  5. Replies: 0
    Last Post: 10-21-2008, 10:51 PM

Tags for this Thread

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