Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Loops within loops

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith - 20 Nov 2006 09:49 GMT
I seem to be having a Monday morning moment.  I have a simple task to code,
but for some reason I can't get my head around it.

I have a recordset open.  That's fine.  I know that there will only be 8
records in this recordset.  What I want to do is populate an Array with a
date that is stored in each record.

I have setup d do while not eof to go through the recordset,  I have the
setup a For next loop (1 to 8) to move through the array.

But unless I am mistaken I will have to go right through the array before I
can move to the next record. Am I correct?

Can somebody help me through my Monday morning fog.  This should be simple.

How can I move the For Next on by 1 then move the recordset on one?
Stefan Hoffmann - 20 Nov 2006 10:00 GMT
hi Keith,

> I seem to be having a Monday morning moment.  I have a simple task to code,
> but for some reason I can't get my head around it.
Seems like your forgot your cup of coffee?

> I have a recordset open.  That's fine.  I know that there will only be 8
> records in this recordset.  What I want to do is populate an Array with a
> date that is stored in each record.

  Dim Count As Long
  Dim Dates() As Date

  rs.MoveLast
  rs.MoveFirst 'if order is important
  Count = rs.RecordCount

  ReDim Preserve Dates(Count - 1)

  For Count = 0 to Count - 1
      Dates(Count) = rs![Date]
      rs.MovePrevious
  Next Count

mfG
--> stefan <--
Keith - 20 Nov 2006 10:15 GMT
Hi Stefan,

That will work great.

Thanks for taking the time to help.  As I said I was having a Monday Morning
moment.

Keith

> hi Keith,
>
[quoted text clipped - 22 lines]
> mfG
> --> stefan <--
Brendan Reynolds - 20 Nov 2006 10:13 GMT
Stefan has shown how to do it with a loop. You might also want to check out
the built-in GetRows method of the Recordset object. Here's a link to the on
line help topic ...

If using DAO ...
http://office.microsoft.com/client/helppreview.aspx?AssetID=HV012039271033

If using ADO ...
http://office.microsoft.com/client/helppreview.aspx?AssetID=HV012286441033

Signature

Brendan Reynolds
Access MVP

>I seem to be having a Monday morning moment.  I have a simple task to code,
> but for some reason I can't get my head around it.
[quoted text clipped - 14 lines]
>
> How can I move the For Next on by 1 then move the recordset on one?
Keith - 20 Nov 2006 10:29 GMT
Unfortunately both pages come up as unavailable

> Stefan has shown how to do it with a loop. You might also want to check out
> the built-in GetRows method of the Recordset object. Here's a link to the on
[quoted text clipped - 24 lines]
> >
> > How can I move the For Next on by 1 then move the recordset on one?
Brendan Reynolds - 20 Nov 2006 13:58 GMT
That's odd. I copied and pasted those URLs from the properties of the
relevant pages, but they come up 'not available' for me, too, now.

You should be able to get to the help topics if you go into the VBA editor
and type 'GetRows' in the 'Type a question for help' box.

Signature

Brendan Reynolds
Access MVP

> Unfortunately both pages come up as unavailable
>
[quoted text clipped - 33 lines]
>> >
>> > How can I move the For Next on by 1 then move the recordset on one?
Keith Wilby - 20 Nov 2006 10:35 GMT
>I seem to be having a Monday morning moment.  I have a simple task to code,
> but for some reason I can't get my head around it.
[quoted text clipped - 14 lines]
>
> How can I move the For Next on by 1 then move the recordset on one?

Care to post your code?

Regards,
Keith.
www.keithwilby.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.