P
Paul
I am trying to get an average from SumOfPalletCount and rs.recordCount but I
get errors no matter how I try and do this...Is there a better way to do
this?
*********What I currently have in a qrytest:***********
PARAMETERS [DaySelected] DateTime;
SELECT RecyHistory.DateRec, Sum(RecyHistory.PalletCount) AS SumOfPalletCount
FROM RecyHistory
GROUP BY RecyHistory.DateRec
HAVING
(((DatePart("w",[RecyHistory].[DateRec]))=DatePart("w",[DaySelected])));
******And Form coding:*********
Private Sub DateRec_GotFocus()
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset
If Not IsDate(Me.DateRec) Then
MsgBox "This value must be a date!"
Me.DateRec.SetFocus
Exit Sub
End If
Set qdf = CurrentDb.QueryDefs("Qrytest")
qdf.Parameters(0) = CDate(Me.DateRec)
Set rs = qdf.OpenRecordset
If rs.EOF Then
Me.Text4 = 0
Else
Me.Text4 = SumOfPalletCount / rs.RecordCount
<------Here is were I get messed up
End If
rs.Close
Set rs = Nothing
qdf.Close
Set qdf = Nothing
get errors no matter how I try and do this...Is there a better way to do
this?
*********What I currently have in a qrytest:***********
PARAMETERS [DaySelected] DateTime;
SELECT RecyHistory.DateRec, Sum(RecyHistory.PalletCount) AS SumOfPalletCount
FROM RecyHistory
GROUP BY RecyHistory.DateRec
HAVING
(((DatePart("w",[RecyHistory].[DateRec]))=DatePart("w",[DaySelected])));
******And Form coding:*********
Private Sub DateRec_GotFocus()
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset
If Not IsDate(Me.DateRec) Then
MsgBox "This value must be a date!"
Me.DateRec.SetFocus
Exit Sub
End If
Set qdf = CurrentDb.QueryDefs("Qrytest")
qdf.Parameters(0) = CDate(Me.DateRec)
Set rs = qdf.OpenRecordset
If rs.EOF Then
Me.Text4 = 0
Else
Me.Text4 = SumOfPalletCount / rs.RecordCount
<------Here is were I get messed up
End If
rs.Close
Set rs = Nothing
qdf.Close
Set qdf = Nothing