Results 1 to 9 of 9
  1. #1
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83

    .MOVEFIRST ADO Object not working

    has this happened for anyone else, usually start access up and get it to renumber the ID on my list of items, but to do this it has to start at the first entry... and for some reason it starts in middle of the list for number 1! this is becoming an issue because I use VBA mostly. Using .MOVENEXT in my loops. I do not get it. I've given up trying to identify where Access's internal pointer actually is. It seems to fly around.

    not that his code will help, but this is how I generally do things:



    Code:
    Dim dbc As Object
    Dim dbd As Object
    Dim fldEnumerator2 As Object
    Dim fldColumns2 As Object
    Set dbc = CurrentDb
    Set dbd = dbc.OpenRecordset("ItemAcceptance")
    dbd.MoveFirst
    curRec = 1: IDcount = 1
    RowCount = 1:
    tries = 0
    curRec = 1: IDcount = 1
    RowCount = 1:
    For abcd = 1 To totalitems
        For Each fldEnumerator2 In dbd.Fields
            If fldEnumerator2.Name = "ID" Then
                dbd.Edit: fldEnumerator2.Value = fldEnumerator2.Value - (smallestRec - 1): dbd.Update
            End If
        Next
    dbd.MoveNext
    Next

  2. #2
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    Here's the example for today:
    1, 10, 11, 12, 13, 14, 15, 16, 2, 3, 4, 5, 6, 7, 8, 9

    trying to get a list of 16

    Code:
    Set dbc = CurrentDb
    Set dbd = dbc.OpenRecordset("Header")
    For i = 1 To 16: dbd.AddNew: dbd("ID").Value = i: dbd.Update: Next
    added in dbd.MoveFirst right after set dbd, and now it gives me error 'no current record'

  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
    For starters, think of the table as a bucket of data with no inherent order. If you want the records in a certain order, open the recordset that way:

    Set dbd = dbc.OpenRecordset("SELECT * FROM ItemAcceptance ORDER BY Whatever")

    Second, what's the purpose of the For Each fldEnumerator2 loop? I don't see one, and you can simply refer to the desired field with:

    dbd!ID

    Unless it's a copy/paste error, you have these lines twice:

    curRec = 1: IDcount = 1
    RowCount = 1:

    And unless they're declared elsewhere, you use a bunch of undeclared variables.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    copy paste error. Thanks for the pointer. I'll change the way the records are opened hopefully that'll do the trick

  5. #5
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    yep, having a tough time with using the table "Header", which initially has no entries. I want to have 16 empty entries (except for the ID) using this routine. It won't take .MOVEFIRST

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem; post back if you're still having a problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    how do I get an entire row to copy onto the next row?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If the table has no entries, the MoveFirst will error, but you don't need it anyway.

    In a recordset you'd have to copy every field. I'd probably use an append query with a criteria.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    good call. Trying to learn so much access at once I forget what the basic methods are.

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

Similar Threads

  1. Replies: 6
    Last Post: 10-04-2012, 01:43 PM
  2. Replies: 1
    Last Post: 04-10-2012, 08:48 AM
  3. Replies: 1
    Last Post: 09-03-2011, 07:01 PM
  4. Replies: 3
    Last Post: 11-02-2010, 10:14 AM
  5. Replies: 1
    Last Post: 08-05-2010, 12: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