Qudsia
Qudsia

Reputation: 53

What do the abbreviations for the BOF and EOF properties mean (stand for) in MS Access VBA code?

End-of/Beginning-of file/field? I understand what these properties are used for but want to confirm what the letters stand for. Tried looking up but everyone, including Microsoft, is explaining what the functions do but no one has spelled out the name.

Upvotes: 0

Views: 662

Answers (2)

Albert D. Kallal
Albert D. Kallal

Reputation: 49264

the term "EOF" was actually quite common in our industry at one time.

think of punched cards, or even reading a file. You are done when you "reach end of file".

However, context here matters. We are not reading a file, but in context of a data table? Well, the term is still used.

Given that ms-access is more then 25 years old (a quarter of a century), then common terms back then in our industry are not all that common today.

So, then this:

Sub FunTest22()

    Dim rstHotels       As DAO.Recordset
    Dim strSQL          As String
    
    
    strSQL = "SELECT ID, HotelName FROM tblHotelsA ORDER BY HotelName"
    
    Set rstHotels = CurrentDb.OpenRecordset(strSQL)
    
    Do While rstHotels.EOF = False
        Debug.Print "id = " & rstHotels!ID, "Hotel Name = " & rstHotels!HotelName
        
        rstHotels.MoveNext    ' move to next row in record set
    Loop
    
    rstHotels.Close
    

End Sub

output in immediate window:

id = 78       Hotel Name = Athabasca Hotel
id = 73       Hotel Name = Banff Aspen Lodge
id = 95       Hotel Name = Best Western
id = 349      Hotel Name = Four Seasons Motor
id = 9        Hotel Name = Four Seasons Motor
id = 10       Hotel Name = Heritage Inn of the South
id = 68       Hotel Name = Holiday Inn Express

So, the typical "use" of EOF (end of file) is as per above.

Upvotes: 1

Gustav
Gustav

Reputation: 55981

Official documentation for files: EOF function.

There is no BOF function, but a LOF function exists (for binary files).

For DAO recordsets, however, both exists, though as properties, not functions, indication the location of the current record pointer:

Recordset.BOF property (DAO)

Recordset.EOF property (DAO)

ADO recordsets have similar properties.

Upvotes: 1

Related Questions