Log in

View Full Version : Settings report variables from form



STTrife
06-15-2012, 07:02 AM
Hi there, I'm trying to so something rather simple,... I think, and i did spent quite a lot of time searching for how to do this, but I keep having the same problem.

I have a form that is linked to a list of student. From that form I want to open a report, that belongs to a specific student.

Now for example, on the report in the page header I added a textbox which referred to 'stnr' that should show the student-number.

I tried messing around with openargs, but no matter what I try, if I use the DoCmd openReport, and open in it preview mode (which is what I want), it always asks for the stnr with a popup box before any VBA code is executed.
So how am I supposed to set this variable before the report opens, so it doesn't ask for it again?

Thanks very much for any help!!!

MacroShadow
06-17-2012, 04:20 AM
This should work
DoCmd.OpenReport"rptReport", acViewPreview,,,"stnr=" & Forms!YourForm!YourTextbox