P
prphan
I am trying to run a code that will pull and print every fifth record in a
recordset. When this runs, I only get the first record in the set. What am
I doing wrong?
Private Sub Every5_Click()
Dim rs As ADODB.Recordset ' Declares rs as ADO Recordset
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection ' Creates open connection to database
Set rs = New ADODB.Recordset
rs.ActiveConnection = cnn1 ' Sets cnn1 as data location for rs
Dim SQL As String
SQL = "SELECT Layout.id, People.name, [dbo_wrk grp].txt,
dbo_ProcedureMain.ProcGroup, dbo_ProcedureMain.ProcNum,
dbo_ProcedureMain.ProcName, Periods.Period, Layout.DLC, Layout.DNC FROM
Periods INNER JOIN ([dbo_wrk grp] INNER JOIN ((Layout INNER JOIN People ON
Layout.Personid = People.id) INNER JOIN dbo_ProcedureMain ON Layout.SOPid =
dbo_ProcedureMain.id) ON [dbo_wrk grp].[wg id] = Layout.Deptid) ON Periods.ID
= Layout.Periodid WHERE (((Layout.id)=" & Me.id & "));"
rs.Open SQL
Dim Rows
For Rows = 0 To 100 Step 5
Next Rows
Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, rs.Fields(2).Value,
rs.Fields(3).Value, rs.Fields(4).Value, rs.Fields(5).Value,
rs.Fields(6).Value, rs.Fields(7).Value
End Sub
recordset. When this runs, I only get the first record in the set. What am
I doing wrong?
Private Sub Every5_Click()
Dim rs As ADODB.Recordset ' Declares rs as ADO Recordset
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection ' Creates open connection to database
Set rs = New ADODB.Recordset
rs.ActiveConnection = cnn1 ' Sets cnn1 as data location for rs
Dim SQL As String
SQL = "SELECT Layout.id, People.name, [dbo_wrk grp].txt,
dbo_ProcedureMain.ProcGroup, dbo_ProcedureMain.ProcNum,
dbo_ProcedureMain.ProcName, Periods.Period, Layout.DLC, Layout.DNC FROM
Periods INNER JOIN ([dbo_wrk grp] INNER JOIN ((Layout INNER JOIN People ON
Layout.Personid = People.id) INNER JOIN dbo_ProcedureMain ON Layout.SOPid =
dbo_ProcedureMain.id) ON [dbo_wrk grp].[wg id] = Layout.Deptid) ON Periods.ID
= Layout.Periodid WHERE (((Layout.id)=" & Me.id & "));"
rs.Open SQL
Dim Rows
For Rows = 0 To 100 Step 5
Next Rows
Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, rs.Fields(2).Value,
rs.Fields(3).Value, rs.Fields(4).Value, rs.Fields(5).Value,
rs.Fields(6).Value, rs.Fields(7).Value
End Sub