Passing variable to a report

owen

New member
Local time
Today, 23:04
Joined
Feb 28, 2009
Messages
8
Please excuse my ignorance, am teaching myself vba whilst trying to construct a database.. my problem is that, in report code, I use a do while (not .eof) loop through a recordset based on a query - within this loop, a variable calculates the number of days for each row then loops to the next. I want this calculation to show in a text box on the report for each row (the other rows are shown on the report directly from the query control sources)
??
 
Contingent on knowing a bit more of what you require, perhaps you can take a different route -- somewhat less complex -- and build a query in which you use the datediff function...and then, once complete and functional, you can create a report in which you use the query as the record source. If so, a search on "datediff" in the Queries forum may help...

Regards,
Tim
 
Hi thanks for that - the reason I used a loop through a recordset was because one of the dates in the calculation was gotten from the previous row - so I moveprevious, get the date, then movenext to carry on - is there another way to grab this previous date. I thought this morning about creating a temporary table and bunging my variables in there as it loops..

sorry again for my basic info - I would paste my code in here but it's an incredible mess with all my trials in there..
 
I don't know how do you loop thru the recordset, but try creating a function that receives a parameter (such as cutomer ID) and makes the calculation you need. Insert a textbox in your report and set its control source to "=myfunction(parm)"
 

Users who are viewing this thread

Back
Top Bottom