Link to home
Start Free TrialLog in
Avatar of jann3891
jann3891Flag for United States of America

asked on

Msaccess, printing between 2 reports

Hello Experts,
I am using MSAccess 2013. Wondering if this is possible.
Company has 100 employees and 10 departments. I flagged each employee with E and S for english and spanish.
I have 2 reports, one english and one spanish.
I need to be able to print a report for each employee sort by, department, and then employee last name.
seems easy, but the tricky part is, it has to print a spanish report for the employee flagged as S and an english report for employees flagged as E.
and still maintain the sort order.
the final result should be the 100 pages sorted accordingly but with english and spanish mixed in..

Is this possible?
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Could you do this with a Master report / Subreport? Have the master report retrieve all of the employees, and hide / show the subreport that matches the desired language? The subreport would need to accept the identifier for the employee.
my first thought would be to create the main report which basically has a recordsource that only includes the fields you need for your sorting, plus the [Language] code field.

Then create an English version and a Spanish version of a subreport.  Put both of those subreports on the form, one on top of the other.  Set their Height to 0 and CanGrow to Yes.

Then use the Detail sections Format event, along with the [Language] field from the main forms recordsource to set the visible property to each of the subreports.  Something like:

Private Sub Detail_Format

    me.subEnglish.visible = me.[Language] = "E"
    me.subSpanish.Visible = me.[Language] = "S"

End sub

This is just an idea, as I have never actually tried this.
Avatar of jann3891

ASKER

thanks for the prompt reply. let me give that a shot and I will report back
i filtered my query to 10 employees only.
it seems to be looking at the first employee, which is E, and then run the remainder of the employees in english, and then the second employee is S, then it run another set for all the 10 employees again in spanish..
so, overall, it generated 100 reports..
can you generate some made up data and send all of the pertinent parts in a dummy database?

I'll take a look tonight and see if I can make that work.
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, i will study this and try to follow. will get back to you soon
Ok, I think I'm following what you did now. but the main report is still not the desired result i was looking for...
the first record is E, so I only want the english to appear and the spanish report to not show at all. and the third page should only show spanish and english should not show... etc..
Then it sounds like you failed to add the code to the report details format section.

Open the example click on the details section header and look at the code associated with the Detail_Format event.  In that code, it uses the value in my [Language] field to show/hide the appropriate report (English or Spanish) for each record.  Only one of those reports should show for each person (but you will have to change my [Language] field to reflect the field in your table that contains the E or S.
I am still working on your sample database you attached, and when I open the rpt_English_Spanish report, it is showing both english and spanish for each record. (see attached)
Capture.JPG
OK, this is a problem with the Report View of Access, which is now the default.  When you view a report in report view, many of the form events do not fire.  Instead of simply double clicking on the report, right click and view it in PrintPreview mode.

When you use PrintPreview, those events will fire.
Oh my, I did not know that. I am barely starting on Access 2013, and also just noticed that I indicated I am using 2013, instead of 2003... anyways, your sample database did work as you said. I will try to replicate this on my database and will report back soon.
Thanks again.
it works !!! thank you very much for taking the time to help me out..
glad to help.  That is what we are here for.