J
James
Ok, I have a function(see below) that prompts for a username, and a date, it
then runs a function based on that user and date. I want to create a report
that will show the info for ALL the users. So I've made a query that
selects all distinct usernames for a date you enter. How would i adjust
this function to get it to use the usernames from my query instead of
prompting for a username, and how would i get it to print out all the data?
Thanks
Function AddTimes()
'Dim db As DAO.Database
'Dim rs As DAO.Recordset
Dim Time1 As Date
Dim time2 As Date
Dim TimeAccum As Integer
'InputUserName = InputBox("Please enter a username")
'InputDate = InputBox("Please enter a Date")
Dim db As Database 'current database
Dim rs As Recordset 'holds query resultset
Dim qdfParmQry As QueryDef 'the actual query object
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Qry_AddTimes")
qdfParmQry("Please Enter a Username:") = ClientUserName
' or try this alternate method
' to pass the parameter
qdfParmQry![Please Enter a Date:] = logDate
Set rs = qdfParmQry.OpenRecordset()
'Set db = CurrentDb
'Set rs = db.OpenRecordset("WebProxyLog")
rs.MoveNext
Do
rs.MovePrevious
Time1 = rs!logTime
rs.MoveNext
time2 = rs!logTime
If DateDiff("n", Time1, time2) < 5 Then
TimeAccum = TimeAccum + DateDiff("n", Time1, time2)
End If
rs.MoveNext
Loop Until rs.EOF
AddTimes = TimeAccum
Debug.Print AddTimes
End Function
then runs a function based on that user and date. I want to create a report
that will show the info for ALL the users. So I've made a query that
selects all distinct usernames for a date you enter. How would i adjust
this function to get it to use the usernames from my query instead of
prompting for a username, and how would i get it to print out all the data?
Thanks
Function AddTimes()
'Dim db As DAO.Database
'Dim rs As DAO.Recordset
Dim Time1 As Date
Dim time2 As Date
Dim TimeAccum As Integer
'InputUserName = InputBox("Please enter a username")
'InputDate = InputBox("Please enter a Date")
Dim db As Database 'current database
Dim rs As Recordset 'holds query resultset
Dim qdfParmQry As QueryDef 'the actual query object
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Qry_AddTimes")
qdfParmQry("Please Enter a Username:") = ClientUserName
' or try this alternate method
' to pass the parameter
qdfParmQry![Please Enter a Date:] = logDate
Set rs = qdfParmQry.OpenRecordset()
'Set db = CurrentDb
'Set rs = db.OpenRecordset("WebProxyLog")
rs.MoveNext
Do
rs.MovePrevious
Time1 = rs!logTime
rs.MoveNext
time2 = rs!logTime
If DateDiff("n", Time1, time2) < 5 Then
TimeAccum = TimeAccum + DateDiff("n", Time1, time2)
End If
rs.MoveNext
Loop Until rs.EOF
AddTimes = TimeAccum
Debug.Print AddTimes
End Function