Problem stepping thru a record set

A

Andrew

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
 
C

chris.nebinger

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top