Report and subreport issues

Posted on 2011-09-08
Last Modified: 2013-11-27
Great Day! I am trying to print an invoice for a customer who has had repair work on his/her vehicle. The Report identifies customer information and other information relative to the repair: mileagein; datein; service writer; etc. I have 2 subforms:

One displays the repair items that were performed during the service: oil change; replace front brake pads; etc.

the other one displays the parts that were purchased for the repair. In the above example, it would be oil, oil filter, and brake pads.

When I use the following filer:

stFilter = "CustomerID=" & Me.CustomerID & "AND [RepairOrderID] =" & Me.RepairOrderId

the report pulls up the same invoice, no matter which CustomerID and RepairID is used as the filter, but it asks for a paramer to open the report: It is asking for a table, which seems odd to me, and the name of it is tblRepair-RepairOrder.

I've struggled with this for a few days, and once you look at it, you will see why.

I am enclosing the ClickEvent code along with the DB. To open the form that calls the Invoice (report), click on frmRepairOrder-Select4Report2, and then click on a repair order and click the "Open Report" button.

Thanks for your assistance in advance.
Private Sub btnOpen_Report_Click()

    Dim stDocName As String
    Dim stFilter As String
    Dim stDateRange As String
    'set conditions
    stDocName = "rptInvoice"
    stFilter = "CustomerID=" & Me.CustomerID & "AND [RepairOrderID] =" & Me.RepairOrderId
    'Open report
    DoCmd.OpenReport stDocName, acPreview, WhereCondition:=stFilter

End Sub

Open in new window
Question by:yddadsjd95
  • 6
  • 5
LVL 77

Expert Comment

ID: 36504618
There is almost certainly more to it than this but you need a space in front of AND

" AND .....

Just as a comment, your filter statement assumes that customerid and repairorderid are both numbers.
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36504641
again, see the posts toward the end of your previous question...

...Perhaps you should wait on this Q until that Q is resolved, avoid contusion...


Author Comment

ID: 36505331
okay, I'm working on it.
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.


Author Comment

ID: 36522797
I haven't forgotten about this, but fixing some other errors of poor design had created new bugs that I must exterminate before getting back to this one.

Author Comment

ID: 36572927
Okay, I'm back on this issue. Since I submitted this question, it was recommended that I rename most of my tables for clarity's sake, which I did. I was hopeful that those modifications would make it easier to figure out the problem in this instance, but no such good fortune today. I did however get rid of the parameter issue, but now the report is displaying more than 100 reports, when there should only be 11.

I have enclosed a copy of the form with all associated tables and queries. Open rptInvoice2.

Thanks for your assistance,


Author Comment

ID: 36573105
FYI, I initially had 9 tables in the Query, but I tried to reduce the number of tables be creating a number of queries that could be used. Consequently, I went from 9 tables to two tables and 3 queries.
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 500 total points
ID: 36574126
1. What size paper are you using?
The page setup is Portrait for orientation, and Letter for the paper size, yet the Report width is 10 inches...
Perhaps this is why you are getting extra pages.

2. There are quite a few things here that make this system more complex than it has to be.
a. First, for whatever design and/or relational reasons, One Job ID in the main report can encompass more than one vehicle.
(ex JobID 59, encompasses two cars under the same Vehicle ID (5)
YearMakeModel      ModYear      Color      VIN      Tag-State
1990 / MERCEDES / SDL350      1990      Beige      HMVD65298736TY78H      MDGWT730
1999 / MERCEDES / E350      1999      Sky Blue            MDBEV 821 it seems that you might want to start here in your troubleshooting.

b. The query for the main report contains data that is already in the subreports, and hence is realy not needed, and complicates things more than needed.
In Other words, the main Report Recordsource need only contain Customer and WorkOrder data.
This will be linked to the subreports via the JobID (WorkoderID or whatever you are calling it...)

Again, I stated early on that you should take a close look at the Northwind Sample DB.
It contains a solid example of this type of situation.
(One Order, many details...)

LVL 74

Accepted Solution

Jeffrey Coachman earned 500 total points
ID: 36574983
FWIW, Here is the design approach I would take...

Author Comment

ID: 36576469
Thanks Jeff, It has been a long day, and I am only half through, but I'll get back to this in a little bit.

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36576540
just remember,...

You can't really take what I,(or any experts here), say as Gospel.
Remember, we don't know the full scope of your application's Design or its requirements, and/or constraints.

Author Closing Comment

ID: 36580273
Thank you Jeff for coming to my aid. Your solution answered my question, but I see now that I should have included the form that called the report, because now there are three records that are showing up in the report as not having in data in them. Anyway, you live and your learn. I will rephrase the question in a new question.

I am really learning a lot though, so all is not lost :-).

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36581615

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question