It would be easier to open a recordset if you wanted to loop through the
records.
Here's an example:
http://allenbrowne.com/func-DAO.html...cordsetExample
It lists the records to the Immediate Window (Ctrl+G) rather than a MsgBox
for each one.
If you need to do this in a form, you can use the RecordsetClone of the
form, i.e.:
Set rs = Me.RecordsetClone
rs.MoveFirst
...
And here's a list of the kind of things people normally get into trouble
with when using recordsets:
Traps: Working with Recordsets - 10 common mistakes
at:
http://allenbrowne.com/ser-29.html
BTW, if you have a background in other databases, you may loop through
recordsets less frequently in Access. You can often perform an operation by
executing one action query instead of visiting each record in turn.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"rev" <sn*********@yahoo.comwrote in message
news:11**********************@o11g2000prd.googlegr oups.com...
Trying to teach myself Access. All I want to do at the moment is loop
through a column and display each row one at a time in a messagebox.
Here's what I have so far:
Private Sub Command0_Click()
DoCmd.OpenTable "mytable"
DoCmd.GoToRecord , , acFirst
DoCmd.GoToControl "myfield"
x = currentrecord.value '>>>this doesnt work...
MsgBox x
total = DCount("*", "mytable") - 1
For x = 1 To total
DoCmd.OpenTable "mytable"
DoCmd.GoToRecord , , acNext
DoCmd.GoToControl "myfield"
x = ???
MsgBox x
Next
End Sub
Any assistance would be GREATLY appreciated!