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.

Problem stepping thru a record set

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 09 Nov 2006 23:19 GMT
Hi I'm using the following code to step thru a recordset.  It works fine but
not in the order of the recordset.

There are 33 records and it goes from record 10 - 33 then 1 - 9.  Can anyone
assist?  It's driving me mad.

Private Sub Btn_Play_Demo_Click()
Dim MyTable As DAO.Recordset
Dim MySet As DAO.Recordset
Dim DB As DAO.Database
Dim MyDB As DAO.Database
Dim iResponse As Integer
Dim l_sFilename As String

Twip = 15

   Set DB = CurrentDb()
'    DoCmd.SetWarnings False
   Set MyDB = CurrentDb
   Set MySet = MyDB.OpenRecordset("Tracked")
   MySet.MoveFirst
   Do Until MySet.EOF
       The_Call_Sign = MySet![Call_Sign]
       The_Date = MySet![The_Date].Value
       The_Time = MySet![The_Time].Value
       Time_Started = Forms.Frm_Form1.Time_Ended
       If IsNull(Time_Started) Then
           Time_Started = 9
       End If
       The_X_Coordinates = MySet![X_Coordinates].Value
       The_Y_Coordinates = MySet![Y_Coordinates].Value
       
       Car1.Left = The_X_Coordinates
       Car1.Top = The_Y_Coordinates
       MsgBox MySet!Call_Sign
       Forms.Frm_Form1.Lat_Deg = MySet!Lat_Degrees
       Forms.Frm_Form1.Lat_Min = MySet!Lat_Minutes
       Forms.Frm_Form1.Lat_Sec = MySet!Lat_Seconds
   
       Forms.Frm_Form1.Lon_Deg = MySet!Lon_Degrees
       Forms.Frm_Form1.Lon_Min = MySet!Lon_Minutes
       Forms.Frm_Form1.Lon_Sec = MySet!Lon_Seconds
   
       Forms.Frm_Form1.Time_Started = Time_Started
       Forms.Frm_Form1.Time_Ended = MySet![The_Time].Value
       Forms.Frm_Form1.Time_Taken = Forms.Frm_Form1.Time_Ended -
Forms.Frm_Form1.Time_Started
   
   Call apWait(2.5)
'        Car1.Left = The_X_Coordinates * Twip - ((Twip * 100) * 0.25)
'       Car1.Top = (The_Y_Coordinates * Twip) - (Twip * 100)
       
       MySet.MoveNext
   Loop
   
   SysCmd acSysCmdSetStatus, " "
   MySet.Close
       
 
 
   DoCmd.SetWarnings True
   MsgBox ("Finished...")
   
End Sub

Signature

Andrew

chris.nebinger@gmail.com - 09 Nov 2006 23:39 GMT
It looks like you are just opening a table.  Records in a table are not
stored in any particular order, so you should order them yourself to
ensure they are coming out the way you want.

Try:

Set MySet = MyDB.OpenRecordset("Tracked")

to:

Set MySet = MyDB.OpenRecordset("Select * from Tracked Order By
Call_Sign")  'Or any other field you want to sort on.

Chris Nebinger

> Hi I'm using the following code to step thru a recordset.  It works fine but
> not in the order of the recordset.
[quoted text clipped - 58 lines]
>    
> End Sub
 
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.