Problem passing values from FORM to REPORT

Kodo

"The Shoe"
Local time
Today, 16:35
Joined
Jan 20, 2004
Messages
707
Using Access2002
My report uses onActivate. Can I not grab the value of the openArgs when using onActivate?

I am using this to collect my values on the form:
PHP:
Private Sub PrintBySingleDepartment_Click()

Dim i As Variant, DeptID As Variant

For Each i In Me.DeptList.ItemsSelected
            DeptID = Me.DeptList.Column(0, i)
                   DoCmd.OpenReport "Monthly Report By Dept", acViewNormal, , , acHidden, DeptID

Next

End Sub

this opens the report and it SHOULD pass the values in the combobox to OpenArgs on the report, but I can't get it to work..


Does anyone have any idea why the value would be NULL all the time ?I've tried .printing Me.OpenArgs on the report and it is always NULL.

Thanks
 
My version of Access (2000 and 97) don't have an OpenArgs property for Reports.

In fact the docmd.OpenReports is structured as follows

Docmd.OpenReport ReportName,View As AcView,FilterName,WhereCondition

You could do this by using a Global Variable, setting the value of a Hidden Text box on the form and then referencing it on the Report_Open Event of the Report (Setting a Report Level Variable)
 
Thanks for the reply!

Access 2002 is the first version to include OpenArgs for reports.

I can't use filter as the report is not bound to a data source.

It's a static report that was recently decided that they need to see for each department.

I have 5 queries in the module behind the report pulling out counts. They want to be able to pull up any number of departments at any time or all at once.. so that is why I opted for the loop and then send to the report.

I think I just may go bald or go home for the day lol. :D
 
Are you at liberty to modify the form? If so consider placing a hidden text box on the form and iterate through the list box placing the key value in the text box each time you find the row selected. You will then call the report for each selected row, passing the value of the text box to the report each time you call it.
for i=1 to mylist.listcount-1
if mylist.selected(i) then
txtreportvar=mylist.column(varcolumn#,i)
'here, call your report, whatever else you want to do
end if
next i
'optional clear mylist selections
for i=1 to mylist.listcount-1
mylist.selected(i)=false
next i
 
I am the only one who has access to the forms ;) it's good to be the king..lol.

Anywho...that's a good idea. so everytime I get a new 'I' value, update the text field and then open the report calling the forms text box value.

Thanks, now I can go smack myself for not thinking about that before..;)
 
well, everything I tried has failed. I can't do the form text box thing because the report wants a collection and every time I tried Forms![formname]![ctrlbox] I got an error.

so I tried a module and put this in it

PHP:
Sub getdeptid(DeptID As Integer)
Dim ReportDeptID As Integer

ReportDeptID = DeptID
    DoCmd.OpenReport "Monthly Report By Dept", acViewNormal, , , acHidden
 
End Sub

Then I tried to get ReportDeptID in the report and the values always came out 0.. so Now I'm totally baffled.
 
my solution:

declare a public (global) variable for the form
call this global variable from the report using the forms collection.

Thank you all for your time :)
 

Users who are viewing this thread

Back
Top Bottom