Jim Hewson
jm.hwsn at gmail.com
Fri Jun 8 09:14:54 CDT 2012
Warning - this is rather long. Windows 7, Access 2007 -- This database has always been in A2007 - so it was never upgraded to a newer version. What I'm trying to do is print several reports using a button on a pop up (modal) form. The form is opened from a button on another form. Behind that form is a master form that stores pertinent data for doing several things and is kept open during the entire session. The database is used as a survey questionnaire. The researcher can can change questions (text, responses, order, question type, etc.), assign questions to sections (max 25), assign variables and question coding . Sections can be ordered in any way the researcher deems necessary. The reason I want to print multiple reports is that each section is a separate report and I want to print the entire questionnaire instead of printing one section at a time. The current questionnaire has 18 sections and therefore has 18 reports to be printed. All reports have sub-reports. Some have sub or sub-sub-reports - depending on the section critieria. The print questionnaire form works -- IF it is opened from the navigation pane. If it is opened by the button on the form - it crashes Access and closes the file. The message I get is "Microsoft Office Access has stopped working Window can try to recover your information and restart the program" My one choice is to "Restart the program". It prints the first section. The original code had a DAO recordset that used a query as a record source. With the recordset, I had a Do While ... Loop to find the specific section and report that needed to be printed in order. I used a DLookup function to find the report needed and then a select Case to find the specific report name. The where clause was in the Loop because it changed for each report. At the end just before the Loop, I had a rsPrint.MoveNext. It appeared that the .MoveNext was the issue because that's where it would crash. So... I read somewhere that maybe the .MoveNext might be culprit and that maybe changing the order of events might work... it didn't. I also read somewhere that maybe I need to put in .MoveFirst and .MoveLast at the beginning... didn't work... either before the With rsPrint statement or after the statement and before the Loop... didn't work. On this forum, I read that maybe I need to validate .BOF = False Or .EOF = False in an If statement and them go on with the Loop.... didn't work. I read that maybe the entire Loop thing was the problem... or even the Select Case was the issue... or the domain funtions... eliminated them... didn't work. I redid the form... it had hidden fields which populated on loading that had the criteria for the where clause and the specific report needed. So all I needed to do was call the field for the Where clause and the report... didn't work. I thought maybe it might be the pop up or modal status was the issue... nope, still crashed. After everything I've done.... I finally come to conclusion that it's crashing just after DoCmd.OpenReport statement... the first report prints but it ALWAYS crashes and doesn't get to the next line. Where can I go from here? Am I stuck telling my users that they can only print one section at a time? Thanks in advance for any insight you have. Jim