What I am doing is extracting data on an employees sign in time and amount of hours worked extracting data by month and day..
Ok I have this a s recordset
Which works like a charm
I would like to extract from this recordset a different way than this if possible.Code:Dim Acct, Days$, StrSql As String Set Record_Sets = New ADODB.Recordset Acct = Val(RRR!Number) Days = Trim(Str(D)) StrSql = "SELECT Month,Start_day,Year,Start_time,Stop_Time,Hours,Min,Overtime " _ & "FROM Pay_Hours " _ & "WHERE Number = '" & Acct & "' And Start_Day ='" & Trim(Str(D)) & "' _ And Month ='" & Trim(Str(S)) & "' " Record_Sets.Open StrSql, Data_Connection(1), adOpenStatic, adLockReadOnly, adCmdText Extract Record_Sets.Close
The Sdata is for print outsCode:Sub Extractor() First_time = 0 Do While Not Record_Sets.EOF col = 0 For Colx = 0 To Record_Sets.Fields.Count - 1 If First_time > 0 Then Exit For If Val(Record_Sets.Fields(0).Value & "") = S _ And Val(Record_Sets.Fields(1).Value & "") = D Then Found = 1 Select Case Colx Case 2 Sdata(Rows(1), 2) = Record_Sets.Fields(3).Value & "" Case 3 Sdata(Rows(1), 3) = Record_Sets.Fields(4).Value & "" Case 4 Sdata(Rows(1), 5) = Record_Sets.Fields(5).Value & "" Case 5 Sdata(Rows(1), 6) = Record_Sets.Fields(6).Value & "" Case 7 Sdata(Rows(1), 7) = Record_Sets.Fields(7).Value & "" End Select End If Next Record_Sets.MoveNext First_time = 1 End Sub
The reason for the First_Time Integer is the extractor would loop twice on me.
One more question does all of the data in a database have to be a variable in order for the recordset to work in the SQl select statement.




Reply With Quote