How do i only produce so that i can view/print only from the form in view? Once I press a button to generate the report
Thanks
How do i only produce so that i can view/print only from the form in view? Once I press a button to generate the report
Thanks
Do not totally understand the objective. What do you want to do with the report, print, save to PDF file, email? You do not want the report to show on the screen, only the form that causes the event to be viewed by the user?
I want it show on screen, then user can print as needed,
But I only want it to show the form that is currently open.
ie:- if i run the report now it has all 269 records what i want is just the report for the record I have open and reviewing.
Hope that makes sense
Does not really make sense but I will guess that you want to open a report in print preview from a form using the forms filtered recordset.
If your report is based on the same query object as your form, the following should work. (untested)
Code:Dim strfilter As String strfilter = "" If Me.FilterOn = True Then strfilter = Me.Filter End If DoCmd.OpenReport "ReportName", acViewPreview, , strfilter, acWindowNormal
i am not sure how this would work, as i have a button on the form to open the report,
say I am looking at Site Number 0272S i want to click the button it opens the report in Print Preview only for 0272S.
Currently if I click the button it will open report in print view but it doesnt filter and the page i see is the first record which is 0001S, which means i have to then click and find the one i actually want.
Hope that makes more sense
Thanks again for yourt help
The example I showed you is VBA. It belongs in an event procedure that handles a given event, like On Click. You can create an event handler by going to the Event tab in the properties sheet, for a given control, and clicking the ellipses(...) next to the event you desire. Be sure to first clear out any text regarding an Embedded Macro before creating the VBA event handler.
Clicking the ellipses will open a window, select "Code Builder". This will launch the VBA Editor and give you a place to write your code.
The code sample depends on the form's filter to then filter the report as it opens.
You can pass criteria to the Docmd.Open report. The example uses the form’s filter property as the criteria. You do not have to use the form's filter criteria. You can pass any criteria you wish.
this line
DoCmd.OpenReport(Front,acViewPreview,strfilter,acW indowNormal)
is coming up with a compile error = Expected
The name of the report is Front?
So maybe
Code:DoCmd.OpenReport "Front", acViewPreview, , strfilter, acWindowNormal
Yes "Front" is the name of the report.
I tried what you said that now opens the report, but the information is missing?
Only the typed woprding is there (ie the part that not tried to anything) and the data that should be there is missing
I just tested the code in Post#4 and it worked for me. Form's filter on, report returns filtered results. Form's filter off, report returns all results.
Does your report share the same Query/Table as its recordsource? The same recordsource as the form?
I have looked at the button properties and I cant see a filter to switch on
Regardless of whether or not the form's filter is turned on or not, your report should open and display, at least, some records. I would address that issue first by verifying the recordsource of the report.
Then you can apply filters to your form using the intrinsic filter tools. Perhaps right clicking in a field will help.
I provided the code guessing that you are filtering records in a form as you view them. You need to tell the report which records you want to view and pass that criteria to the Docmd.OpenReport.
So I added this
Private Sub Command594_Click()
Dim strfilter As String
strfilter = ""
If Me.FilterOn = True Then
strfilter = Me.Filter
End If
DoCmd.OpenReport "Front", acViewPreview
End Sub
this shows all the data but for all the forms. so there is something not working on the filter part, when i add the filter , strfilter, acWindowNormal to the end of that line the data is missing again
The filter element is simply the actual form in view which as the Site Code as its primary key
That was not the behavior I got this morning when I tested the code.
Are you trying to filter the report to a single record? You can pass that argument directly to the Docmd. What is the name of the field that is the Primary Key?
yeah all i want to do is open a REPORT of the form that i currently have open.
otherwise i will have 2000 pages of the report and then i have to work out what page the report i want to print it
The primary key is SITE NUMBER