June7
AWF VIP
- Local time
- Yesterday, 23:12
- Joined
- Mar 9, 2014
- Messages
- 5,770
Last edited:
SELECT D.*
FROM tblData AS D, ptblParameters AS P
WHERE D.Anydate = P.parDate
sSQL = "TRANSFORM ..." & _
" WHERE P.PDATE = " & Format(Forms.AnyForm.txtAnyDate, "\#yyyy\-mm\-dd\#") & _
" ..."
csSQL = "TRANSFORM ..." & _
" WHERE P.PDATE = [$1Date]" & _
" ..."
sSQL = Replace(csSQL, "$1Date", Format(Forms.AnyForm.txtAnyDate, "\#yyyy\-mm\-dd\#"))
I use them all the time. But, I have no doubt that some Access version or other might have a problemForm references and TempVar have problems as parameter passers when they are used at a deeper level (subquery)
Surely that is 'since' 2007 ?TempVars are only available with Acc2007
Correct. Someone is reading along, I'm thrilled.'since' 2007 ?
Hi ebs17,I inserted the SQL string from one query into the crosstab query. Passing parameters to ONE object is clearer.
To pass parameters, I have chosen a public function as a variant. This function takes the (validated) Date value from a form text field.
Code:Public Function fctparDate() As Date fctparDate = Forms.AnyForm.txtAnyDate End Function
SQL:TRANSFORM SUM(Q.AMOUNTPAID) AS SumOfAMOUNTPAID SELECT Q.BUYERID, B.byrFName, B.byrLName, B.propID, B.propBlk, B.propLot, B.propSQM, Q.PDATE, Q.ARNO, Q.BankName, Q.AccNo, Q.AccName, SUM(Q.AMOUNTPAID) AS [Total Of AMOUNTPAID] FROM tblBuyer AS B INNER JOIN ( SELECT P.PAYID, P.BUYERID, P.PDATE, P.ARNO, P.AMOUNTPAID, P.MOPID, M.MOP, M.BankName, M.AccNo, M.AccName, P.REFTRANSNMBR, P.REMARKS FROM tblMOP AS M INNER JOIN tblPayment AS P ON M.MopID = P.MOPID WHERE P.PDATE = fctparDate() ) AS Q ON B.byrID = Q.BUYERID GROUP BY Q.BUYERID, B.byrFName, B.byrLName, B.propID, B.propBlk, B.propLot, B.propSQM, Q.PDATE, Q.ARNO, Q.BankName, Q.AccNo, Q.AccName PIVOT Q.MOPID
There are at least three other variants.
Hi CJ_London,So where in that sql have you assigned the parameter - see post #5
I would have expected to see something like
Code:PARAMETERS [Enter Date] Date; SELECT tblPayment.PAYID, tblPayment.BUYERID, tblPayment.PDATE, tblPayment.ARNO, tblPayment.AMOUNTPAID, tblPayment.MOPID, tblMOP.MOP, ... ...
Yes.. i did read it.. the problem i am struggling to get work is the date range filter..Did you read Allen Browne article linked in post 21?
Exactly what do you not understand?
Build crosstab query - use the build wizard if that helps. Modify design - open Parameters dialog with button on ribbon.
You do not name modules the same as sub or function names.Hi ebs17,
Thank you for helping me to my query and crosstab.. I pasted your sql statement into the sql design view of my crosstab, then I copied your fctparDate function into module, and save as "fctparDate"..but when open/run my crosstab, I got the attached msg..
Can you please guide me on how to use your sql and function.. I am new to advance queries/crosstab pls need more help.
Thank you.
It must be a standard module, not a form's module. And of course the form being accessed must also be open at this moment and contain a valid value.I copied your fctparDate function into module
not sure how much easier it could be - in the query window on the ribbonCan you please expand the above,