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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there and EOF/BOF to use with DoCmd.GoToRecord next? 1

Status
Not open for further replies.

brettatexplace

Technical User
Mar 8, 2002
60
CA
I want to open a form, Goto the first record, loop to the last record and collect up info from a string field.

I want to use something like....

if (at least one record) then !need code here!
DoCmd.GotoRecord First
string_now_is = string_now_is & someField
while (not eof) !need code here!
DoCmd.GotoRecord Next
string_now_is = string_now_is & someField
end while

What can I use for VBA to ask EOF and BOF in my form?? Thanks everyone.
 
Don't loop with that method, fetch the form recordset

<air code - needs a reference to Microsoft DAO 3.# Object library, in VBE - Tools | References>

[tt]dim rs as dao.recordset
set rs=me.recordsetclone
if rs.recordcount > 0 then
rs.movefirst
do while not rs.eof
' do something important
rs.movenext
loop
set rs = nothing[/tt]

Roy-Vidar
 
I was trying that but was getting...

User-defined type not define.

but did not know where to set the reference. Thanks very much!!! Works great!
 
Hello again. I tied it again and it seems to be going throught the records the proper number of loops but seems to pull data only from first record. How do I properly reference a field? using the record set?? or do I need to explicilty retrieve the record each loop??
 
For instance

[tt]msgbox rs.fields("NameOfField").value[/tt]

within the loop

Roy-Vidar
 
The method I use to refer to a field in a record set is by using the ! operator....

With rs
.MoveFirst
Do Until .EOF
string_now_is = string_now_is & rs!SomeField
.MoveNext
Loop
End With



Randy
 
Thanks Roy-Vidar and Randy! Eveything is well in the Universe again. Its great to get stuck on something, post it here, and find e-mail notifications in my morning mail to solve them. :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top