Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No current record error for code that worked in previous version of Access

Status
Not open for further replies.

xyle

Programmer
Jul 2, 2003
23
0
0
US
After upgrading from previous version of Access to Access 2013 I get "Run-time error '3021': No current record.". When I debug it high lights the rec.MoveFirst.

Code:
Dim rec As Recordset
Dim db As Database
Dim strFullBillingBase As String

strFullBillingBase = "SELECT FullBillingBaseFile.*, * FROM FullBillingBaseFile;"
Set db = CurrentDb()
Set rec = db.OpenRecordset(strFullBillingBase)
        
rec.MoveFirst
Do Until rec.EOF
    FullOwner = rec.Fields("Owner Name")
    '
    'rest of code
    '
    rec.MoveNext
Loop
 
Try:

Code:
With rec[blue]
    If .EOF <> .BOF Then[/blue]
        .MoveFirst
        Do Until .EOF
            FullOwner = .Fields("Owner Name")
            '
            'rest of code
            '
            .MoveNext
        Loop [blue]
    End If[/blue]
End With

You may just have an empty recordset...

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Such a rookie mistake thanks Andy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top