Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2006, 11:36 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default EOF

Hey guys, I'm having a problem getting my code to recognize EOF.
I get a "no current record" error message when it hits the bold line below. When I debug I find that the error message is correct b/c iSortKey = 1, and the last record in that field for rsMatch is 1 so the next would be the EOF. But, the code shouldn't even get that far b/c rsMatch.EOF = True. For some reason its not getting out of the loop. Do I have something wrong?

Code:
    iCount = 1
    rsMatch.MoveFirst
    iSortKey = rsMatch![SortKey]
    iRevKey = rsRev![SORT KEY]
    While Not rsMatch.EOF
        If iCount <> 1 Then
            rsMatch.MoveNext
            iSortKey = rsMatch![SortKey]
        End If
        Do Until iSortKey = iRevKey
                If rsRev.EOF Then
                    rsRev.MoveFirst
                End If
            rsRev.MoveNext
            iRevKey = rsRev![SORT KEY]
        Loop

        If rsRev![BREAKPT] <> rsMatch![breakpoint] Then
            rsRev.MoveFirst
            While Not rsRev.EOF
                iCurrentKey = rsRev![SORT KEY]
                rsRev.Edit
                If rsRev![SORT KEY] >= iRevKey Then
                    rsRev![SORT KEY] = iCurrentKey + 1
                End If
                rsRev.Update
                rsRev.MoveNext
            Wend
        End If

        iCount = iCount + 1
    Wend


 
Old December 21st, 2006, 11:54 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

You are right in your assumption, but then you do a MoveNext just before you evaluate, so now it is at the end of the file...

    While Not rsMatch.EOF (not at end of file)
        If iCount <> 1 Then
            rsMatch.MoveNext (now at end of file)
            iSortKey = rsMatch![SortKey] (nothing to evaluate, so error!)
        End If

You will need to move your MoveNext or handle your error appropriately...

Hope it helps, second pair of eyes often does!
 
Old December 21st, 2006, 12:41 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Awesome leehambly! That was it. I just had to move the MoveNext to the bottom of the loop.

Thanks,

Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
C#: EOF using StreamReader shazia1 VS.NET 2002/2003 0 August 16th, 2005 04:25 AM
HELP WITH EOF chiraagb Classic ASP Databases 12 May 6th, 2004 04:51 AM
While not EOF goplayoutside VB.NET 2002/2003 Basics 3 April 22nd, 2004 04:14 PM
EOF in ODBC spraveens PHP Databases 3 March 29th, 2004 12:17 AM
eof new BOOK: Beginning Visual C++ 6 0 October 9th, 2003 07:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.