S
Steven
I am calling this function with:
All v.... variables are Dim As Double
Call retValues(vTestCo, vTestAcct, vTestDept, vTestPeriod, " Tables INNER
JOINED ", " WHERE ....... ")
Public Function retValues(ByRef vTestCo, ByRef vTestAcct, ByRef vTestDept,
ByRef vTestPeriod, TableName As String, WhereClause As
String) As String
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT Count(*) as vCount " & _
"FROM " & TableName & " " & _
"WHERE " & WhereClause
Set rs = CurrentDb.OpenRecordset(strSQL)
rs.MoveFirst
vTestCo = Nz(rs!vCount, 0)
MsgBox vTestCo
rs.Close
Set rs = Nothing
End Function
By doing what I have in the SELECT I am getting all the total records
returned on the vTestCo. That is not what I want. I am looking for 4
individual totals. The query below returns all the records at one time. It
came from buiding a new Query and taking the SQL. I want to return the
Count(*) for each of items individually in the WHERE clause. That is where I
get the vTestCo ... Acct ... Dept ... Period.
SELECT Batch09.*, Nz([Co].[Status],0) AS Expr1,
Nz([ChartOfAccounts].[Active]) AS Expr3, Nz([Dept].[Status],0) AS Expr2,
Nz([C001],"X") AS Expr4
FROM (((Batch09 LEFT JOIN Co ON Batch09.Co = Co.Co) LEFT JOIN
ChartOfAccounts ON (Batch09.Account = ChartOfAccounts.Account) AND
(Batch09.Co = ChartOfAccounts.Co)) LEFT JOIN Dept ON Batch09.Account =
Dept.DeptNum) LEFT JOIN Period ON Batch09.Period = Period.Period
WHERE (((Nz([Co].[Status],0))=0)) OR (((Nz([ChartOfAccounts].[Active]))=0))
OR (((Nz([Dept].[Status],0))=0)) OR (((Nz([C001],"X"))<>"O"));
Thank you for your help.
Steven
All v.... variables are Dim As Double
Call retValues(vTestCo, vTestAcct, vTestDept, vTestPeriod, " Tables INNER
JOINED ", " WHERE ....... ")
Public Function retValues(ByRef vTestCo, ByRef vTestAcct, ByRef vTestDept,
ByRef vTestPeriod, TableName As String, WhereClause As
String) As String
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT Count(*) as vCount " & _
"FROM " & TableName & " " & _
"WHERE " & WhereClause
Set rs = CurrentDb.OpenRecordset(strSQL)
rs.MoveFirst
vTestCo = Nz(rs!vCount, 0)
MsgBox vTestCo
rs.Close
Set rs = Nothing
End Function
By doing what I have in the SELECT I am getting all the total records
returned on the vTestCo. That is not what I want. I am looking for 4
individual totals. The query below returns all the records at one time. It
came from buiding a new Query and taking the SQL. I want to return the
Count(*) for each of items individually in the WHERE clause. That is where I
get the vTestCo ... Acct ... Dept ... Period.
SELECT Batch09.*, Nz([Co].[Status],0) AS Expr1,
Nz([ChartOfAccounts].[Active]) AS Expr3, Nz([Dept].[Status],0) AS Expr2,
Nz([C001],"X") AS Expr4
FROM (((Batch09 LEFT JOIN Co ON Batch09.Co = Co.Co) LEFT JOIN
ChartOfAccounts ON (Batch09.Account = ChartOfAccounts.Account) AND
(Batch09.Co = ChartOfAccounts.Co)) LEFT JOIN Dept ON Batch09.Account =
Dept.DeptNum) LEFT JOIN Period ON Batch09.Period = Period.Period
WHERE (((Nz([Co].[Status],0))=0)) OR (((Nz([ChartOfAccounts].[Active]))=0))
OR (((Nz([Dept].[Status],0))=0)) OR (((Nz([C001],"X"))<>"O"));
Thank you for your help.
Steven