So if I am interpreting what you are saying correctly you want the user to choose which record to include in the report?
The way that comes to my mind is sloppy and most likely wrong but, it would work.
If a real developer saw my current project they would probally gouge out thier own eyes.
Anyway, maybe a table (temp?) that when the user clicks on "Include in Report" the case number is added to this table. When it is time to print the button queries the records that have the case number in the new table, prints the form then clears the new tables data.
seems to me would work in a single user environment. Usure about a multiple user one.
Take my answer with a grain of salt, no others replied so there you go.
I think I know what the problem is. Basically it's based around the small bit of code that one uses to print out a single report from a form. I created a button which sends the user to the preview of the report on the correct page.
Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String
Problem is that the form by itself simply previews the current record. But the form also contains the data in a subform which is the key info I need.
Include in report
What i want is to be able to customise a report so that when someone clicks Include in report for one of the records in the sub DB, then it's included in the details.
I've actually done it, but the problem is that i won't appear when I click the coded button, because the filter changes to Case_number. I can't filter the Include_in_report because it says that It can't find the field (probably because it's in the subform).
My theory is that if there is a way of modifying the below code for the button:
strCriteria = "[Case_number]=" & Me![Case_number]
so that I could also add [include_in_report] = 'yes' in, then it would print off the single report and also include the sub DB details for that record which only have Include in report clicked.
I've got to be honest. I am a very below par programmer. I tend to learn from sites like these, but I only know the very basics.
Help is really appreciated.
I'm not sure how to do the TEMP table thing that you've mentioned.
My logic is that you have not told the code the value is on the subform not the main form, maybe that is why it can't find it. the above (in my logic) would force a matching of main form and subform case numbers as well as only those with the same case number that you have checked off to include in your report.
The line gets highlighted and then I get a syntax error
Is there any other way to do it?
Basically what we have is a paternity testing database
The clients details are entered into the main db while it has linked subforms with the persons getting the tests done.
Now for example, there are three people being tested, John, Amy and Michael. Amy and Michael are living elsewhere and their tests are seperate while John lives elsewhere as well
So I need to generate two letters, one for John saying "enclosed is a sampling kit, etc."
And another for Amy and Michael saying "enclosed are two sampling kits"
It sounds simple and I've managed to sort out the report form etc, but I want to be able to click a button from the main DB form and invoke all the fields in the current subform which have the "include_in_report" selected as yes (this is a Lookup Yes No field).
The idea at the top of this message seems to be in the right direction, but it keeps giving syntax errors.
For the sake of saving you grief, is there any way you could make a copy of your database (removing pertinent data and replace with dummy data), ZIP it down and then POST it here for someone to look at and analyze for you? That would save a lot of time and might get your result the first time.
Not totally sure if this is your situation but take a look at my three posted images and see if they represent what you are trying to do.
Image1: I have a form for Vendors and SubForm with PO's I placed to a Vendor. There are several PO's to each particular Vendor,
Image2: HOWEVER, when I wish to print only certain PO's or Lines for that Vendor, I click the CheckBox that just says PRINT.
Image3: THEN the Report shows up with ONLY the ones that I selected to show with the CheckBox.
Like I said, I might not understand your situation clearly and am trying to. So let me know it this is along the lines of what you're trying to achieve.
The basic command to create a button to preview the current form in a report is straightforward. I got the code from various sites. The only changes I made were adding my report name "Transaction summary" and a field in the current form "Case_number" It can be any field, but from what I understand is that if its not a number field, then you have to add some quotes on the end of th strCriteria command.
Private Sub Command67_Click()
Dim strReportName As String
Dim strCriteria As String
What this does is invoke the report. The report singles out Case_number in a filter and makes the current record the filter. Problem is that this overides any filter you put into a report.
All did to resolve this was to go into the query for that report and put the filter directly into the query. In my case it was Include_in_report=Yes. And it worked. I had to make a copy of the query as the Include_in_report command would then go across the board in my query if I used it in another form, etc.
I have a feeling that this should work: can you just include in the data source for the report the include_in_report field (ie the query underlying it) and put under the criteria for that field 'YES'? That way only records with 'YES' filled out would ever show up in your report, and you wouldn't even need to have that field show up on your report. I hope that this is helpful.