I have built a kiosk type setup within MS Access 2013 using VBA to Maximize the screen so users cannot click on the All Access Objects, ribbon, tools, INCLUDING the print button.
They exclusively fill out sub-forms created within a tabbed Form. These sub-forms feed to reports that I use VBA buttons to print out, however it prints out the ENTIRE form. Users are using right-click on forms, using a text filter to get the info they need from the report, and pressing my print button that is printing the ENTIRE form. What VBA code do I need to use to print EXACTLY what they are seeing in the sub-form after they have filtered it.
Brohagen:
This causes the report to ONLY show that date with those students under it. I need a button now to print that.
In that case it may help to know that when a filter is applied to a Form or Report object then that object has its .Filter property updated to reflect the filtering.
Also, when using the DoCmd.OpenReport() procedure there is a parameter called WhereCondition that can be used to filter the Report . This property expects a string of the same format as found in the .Filter property.
Thus, your code would probably look something like : - With Me
-
Call DoCmd.OpenReport(ReportName:=.Name, WhereCondition:=.Filter)
-
End With
9 3669
Have you created a Report based on the data in your Subform?
Phil
Yes. One tab contains all the Subforms the users completes. Another tab contains all the Reports with data from the Subforms. We use it for an Orientation class. The forms allow the users to add students to classes on certain dates. The user then click on a tab that contains the Report with all the students grouped by the date of orientation. Users are right clicking on the dates, and using a text filter so the report only shows students for a certain date. I need a button they can click to print that view or filtered report. My current VBA button only prints the ENTIRE unfiltered report.
So what is the Record Source for the subform and what is the filter and how are you applying it.
Basically the Record Source for the Report and Subform should be the same, and then you apply the same filter to it.
On your button you will have some code like -
Private Sub CmdPrint_Click()
-
-
Dim strWhere As String
-
-
strWhere = ' This is the bit that needs sorting out
-
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
-
End If
-
-
End Sub
-
So we need to know how the filter for the Subform is obtained, and the strWhere will probably be the same.
Phil
Sorry. Slightly confused. Both the report and form were built from a query named "Orientation_Info_qry". Is that what you are asking?
NeoPa 32,556
Expert Mod 16PB
Hi Brohagen.
You may notice, when working with Access and other Office applications too, that many items have properties. Forms, Reports, etc, and even the Controls and Sections on these objects, have a whole bunch of properties that can be seen when the Properties Pane is open (It's a must to have the Properties Pane open while doing any designing).
When you look at these objects that you're discussing, one of the properties, that's common to both, is called Record Source . From the code it's referred to as .RecordSource . The value in there is what Phil's asking about.
Yes I got that. I currently have a button on the Report that prints the report: - DoCmd.OpenReport "rpt_Orientation_Report1", acViewNormal
I understand I can update the button VBA to print out a filtered view of the Report.
However, users are looking at the entire report, right clicking on a certain date, and applying their own Text Filter directly to the Report. After they have done that they click the button and it prints out the entire report.
I am not applying the filters. Users are directly on the Report. If you open a Report in MS ACCESS you can right click on date or string, and apply a filter to it. For example, again with the Orientation classes; there are students grouped by class date. There may be 5 dates with up to 30 students under each date. Users are right clicking on a date and using a "Equals '15 Sept 17'" string filter. This causes the report to ONLY show that date with those students under it. I need a button now to print that.
NeoPa 32,556
Expert Mod 16PB Brohagen:
This causes the report to ONLY show that date with those students under it. I need a button now to print that.
In that case it may help to know that when a filter is applied to a Form or Report object then that object has its .Filter property updated to reflect the filtering.
Also, when using the DoCmd.OpenReport() procedure there is a parameter called WhereCondition that can be used to filter the Report . This property expects a string of the same format as found in the .Filter property.
Thus, your code would probably look something like : - With Me
-
Call DoCmd.OpenReport(ReportName:=.Name, WhereCondition:=.Filter)
-
End With
YES! This is the answer! Thank you NeoPa. My VBA is novice at best but you took my situation and delivered. I've been Googling for months for the answer. Much appreciated.
NeoPa 32,556
Expert Mod 16PB
Always a pleasure.
A very similar situation happened to me on 19th October 2006 (No I didn't need to look it up). I've been posting here ever since.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Downstreamer |
last post by:
Design is as follows:
A form for the user to input criteria to be used as the where part of
the report's recordsource. This includes a multiselect list box as part
of the criteria selection.
...
|
by: Ellen Manning |
last post by:
I've got an A2K report showing students and their costs. Student info
is in the main report and costs are in a subreport for each student.
The user inputs the program desired then only those...
|
by: Mbishr |
last post by:
i add a print button to print the report and the on demand Subreport crystal
i try this code in the button
crReportDocumentForex.PrintToPrinter(1, False, 1, 99)
but it print the main report...
|
by: hjozinovic |
last post by:
Hi!
I have a MainForm and a SubForm on it. They're linked and can be filtered, sorted etc...
I designed MainReport and SubReport that should match filter and sort criteria from MainForm and...
|
by: youngac |
last post by:
I created a report containing a subreport on an XP Pro machine running
Access 2003 (using 2000 format for the database) . It is a student
report card. The main report contains the student name etc....
|
by: KADANS |
last post by:
Hello,
I'm an technical designer, trying to get information out of a database (access2003).
Recently my company has installed an new drawingprogramma, one which has links with a database. So...
|
by: Whodat! |
last post by:
I am sure that this has been hashed and rehashed but I am unable to
find an answer to my question. I have a report that contains multiple
subreports. The subreports may or may not contain data to...
|
by: Ang |
last post by:
Hi all,
I'm going to print out a user list, which some users has purchase sth
and some users has not.
Therefore I need to print a subreport if the user has purchase, no
subreport when the...
|
by: Brilstern |
last post by:
Ok,
I have a report that is opened up with a filter to a certain person's Equipment Custody Receipt card(ECR). Within this report are two subreports that are linked to the master field on the...
|
by: eye707 |
last post by:
I created a form to choose records by last name. After selecting the name with a combo box, I want the command button to open a report with just that record (or those records) showing. When it...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |