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.

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.
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now