All
I have to export an Access table to an Excel-file. The XLS would be some kind of report with a page title, subtitles, subfooters, footers.
I am currently in debugging state as I can't solve the "No current record" error.
A very basic example of my code is below. I do know why the error happens, but I need a proper solution how to avoid the error message.
Code:
Private Sub Command0_Click()
Dim OrigPostalCode As Integer
Dim OrigFullName As String
Dim OrigStreet As String
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("select * from tblAdres order by postalcode, street, fullname")
Debug.Print "Overview of adres"
rs.MoveFirst
OrigPostalCode = rs!postalcode
Do While Not rs.EOF And rs!postalcode = OrigPostalCode
Debug.Print vbTab & "The postal code is " & rs!postalcode
OrigStreet = rs!street
Do While Not rs.EOF And rs!postalcode = OrigPostalCode And rs!street = OrigStreet
Debug.Print vbTab & vbTab & "A street found for this postal code is: " & rs!street
OrigFullName = rs!FullName
Do While Not rs.EOF And rs!postalcode = OrigPostalCode And rs!street = OrigStreet And rs!FullName = OrigFullName
Debug.Print vbTab & vbTab & vbTab & "A person living in this street is: " & rs!FullName
rs.MoveNext
OrigFullName = rs!FullName
Loop
OrigStreet = rs!street
Loop
OrigPostalCode = rs!postalcode
Loop
End Sub
I do get my report, but I do not find a proper solution for the error message.
Code:
Overview of adres
The postal code is 1000
A street found for this postal code is: Shrekstreet
A person living in this street is: Mike Meyers
A street found for this postal code is: Suite 750
A person living in this street is: Lynda Blair
The postal code is 2000
A street found for this postal code is: Boulevard
A person living in this street is: Joe Smith
A person living in this street is: John X
A street found for this postal code is: Saint Victor
A person living in this street is: Julie Andrews