Re: Looping through Table records.
From: Sandra Daigle (Invalid_at_KeepYourSpam.org)
Date: 06/09/04
- Next message: Chris Nebinger: "Retrive Form to Subform value"
- Previous message: Sandra Daigle: "Re: Looping through Table records."
- In reply to: anonymous_at_discussions.microsoft.com: "Re: Looping through Table records."
- Next in thread: Chris Nebinger: "Looping through Table records."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Jun 2004 11:38:04 -0400
Beginning of File. This condition is true if the current record is before
the first record - meaning that you have navigated past the first record.
When BOF and EOF are both true the recordset is empty.
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
anonymous@discussions.microsoft.com wrote:
> Sorry to post again, but just out of curiosity, what does
> BOF mean? I know EOF is End Of File, but don't know what
> BOF means.
>
>
>> -----Original Message-----
>> Hi Mike,
>>
>> Here is some very basic code to work with a recordset. A recordset is
>> actually an object defined by DAO or ADO which is used for data
>> access. I prefer DAO and in the following example you will see that
>> the code opens a recordset object using some SQL, then using the
>> navigation methods of the recordset, moves through the records one
>> by one until the EOF (End of File) conditon is true. DAO is fairly
>> easy to master but you may want to spend some time in help or with a
>> good book on the subject while you get more familiar with it.
>>
>> dim rst as dao.recordset
>> dim db as dao.database
>> set db=currentdb()
>> 'Change this to your SQL or to the name of a saved query
>> set rst=db.openrecordset("Select * from Mytable;")
>> with rst
>> ' Very important to avoid errors if no records are returned
>> if not (.eof and .bof) then
>> 'movefirst isn't strictly necessary - but just in case
>> .movefirst
>> do until .eof
>> 'do something with record
>> 'reference any fields as I've referenced PKid below
>> msgbox "PkId is: " & .fields("PKid").value
>> .movenext
>> loop
>> endif
>> .close
>> end with
>> set rst=nothing
>> set db=nothing
>>
>>
>> --
>> Sandra Daigle [Microsoft Access MVP]
>> Please post all replies to the newsgroup.
>>
>>
>> Mike wrote:
>>> I was wondering if there is a way to loop through a table,
>>> check a field in each record, and then display a message
>>> box.
>>>
>>> For example, each record has an expiry date, and I want to
>>> compare each expiry date (datExpires) to the current date
>>> (Date()). eg: datExpires <= Date() then msgbox("The
>>> product has expired)
>>>
>>> I attempted doing this with a macro, but it did not have
>>> the degree of control that I was looking for. So, I
>>> decided I want to do this in Visual Basic code.
>>>
>>> I know how to do loops, if statements, and all of that
>>> basic stuff. My problem is looping through a table. Is a
>>> table an array? Does it have a value that can return the
>>> number of records?
>>>
>>> For example, can I do something like Tables!
>>> [tblName].numberOfRecords (or something similar) and then
>>> look at each individual record using an index.
>>>
>>> I know this may sound a little confusing, but any help
>>> would be greatly appreciated.
>>
>>
>> .
- Next message: Chris Nebinger: "Retrive Form to Subform value"
- Previous message: Sandra Daigle: "Re: Looping through Table records."
- In reply to: anonymous_at_discussions.microsoft.com: "Re: Looping through Table records."
- Next in thread: Chris Nebinger: "Looping through Table records."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|