Hi. im trying to setup a filter for a report. Let me explain what I would like to achieve. I have a form called Invoicing, here all the data is put in about the invoice, I then have a report also called invoicing. I would like to be on the invoicing form and click a button saying view invoice, this then takes the invoice number from the form and filters out all the other invoices so only that 1 invoice is shown.
Details of the fields, forms and reports:
Report Details:
Report name: Invoicing
The invoice number field is called: Invoice Number
Form details:
Form name: Invoicing
The invoice number field is called: Invoice Number
I have tried putting the following code into the reports on open event procedure:
Private Sub Report_Open(Cancel As Integer)
Me.Filter = "Invoice Number = " & Form_Invoicing.[Invoice Number].Value
Me.FilterOn = True
End Sub
Can some one please help me.
2 1897
I assume you're using MS Access, I would (through the click event) pass the Invoice Number to a report query and create the report off of that, or, if you want to use a Filter, set up the report based off the same query.
(I placed mine in a Sub and call it from different forms and filter by selected choices)
'Calling print report sub -
Call PrintReports("Form_01", sFilterBy, iFilterBy)
-
Sub: -
Private Sub PrintReports(sReportName As String, sFilterBy As String, iFilterField As Integer)
-
Dim sFieldName As String
-
On Error GoTo ErrHandler
-
-
Select Case iFilterField
-
Case 1
-
sFieldName = "Submitted = '"
-
Case 2
-
sFieldName = "ProgramSupervisor = '"
-
Case 3
-
sFieldName = "ProgramManager = '"
-
End Select
-
-
If sFilterBy = "All Request" Or sFilterBy = "" Then
-
DoCmd.Maximize
-
DoCmd.OpenReport sReportName, acPreview
-
DoCmd.RunCommand acCmdZoom75
-
'DoCmd.Maximize
-
Else
-
'DoCmd.OpenReport stDocName, acViewPreview, , sFilterBy
-
DoCmd.OpenReport sReportName, acViewPreview, , sFieldName & sFilterBy & "'"
-
DoCmd.RunCommand acCmdZoom75
-
End If
-
-
-
Exit Sub
-
ErrHandler:
-
MsgBox "Error printing reports, Error # " & Err.Number & ", " & Err.Description, vbOKOnly, "Error"
-
End Sub
-
Hi. im trying to setup a filter for a report. Let me explain what I would like to achieve. I have a form called Invoicing, here all the data is put in about the invoice, I then have a report also called invoicing. I would like to be on the invoicing form and click a button saying view invoice, this then takes the invoice number from the form and filters out all the other invoices so only that 1 invoice is shown.
Details of the fields, forms and reports:
Report Details:
Report name: Invoicing
The invoice number field is called: Invoice Number
Form details:
Form name: Invoicing
The invoice number field is called: Invoice Number
I have tried putting the following code into the reports on open event procedure:
Private Sub Report_Open(Cancel As Integer)
Me.Filter = "Invoice Number = " & Form_Invoicing.[Invoice Number].Value
Me.FilterOn = True
End Sub
Can some one please help me.
Hi, yes I am using MS Access, I actually managed to figure out the code before I saw the post from CaptainD (Thanks anyhow). This is the code I ended up using:
Private Sub Command51_Click()
On Error GoTo Err_Command51_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Invoices"
stLinkCriteria = "[Invoice Number]=" & Me![Invoice Number]
DoCmd.OpenReport stDocName, A_PREVIEW, , stLinkCriteria
Exit_Command51_Click:
Exit Sub
Err_Command51_Click:
MsgBox Err.Description
Resume Exit_Command51_Click
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dalan |
last post by:
Okay, I have worked on this and then some, but cannot seem to crack
it. So if someone can straighten my code out, or suggest a new
approach, then I'm all ears.
Here goes: I have two tables - one...
|
by: Richard |
last post by:
Hi,
I have a form that take some time to load due to many comboboxes and at
least 8 subforms.
When I filter or sort the main form I get an error message and then Access
shuts down. They ask if...
|
by: diskoduro |
last post by:
Hi!
I'm trying to get help to an unexpected problem that has appeared
while I was writing a new application.
I want to opeon a report of product sales by filtering previously from
a listbox in a...
|
by: Scott Loupin |
last post by:
I've got two databases with similar data in them (WestSide and EastSide).
I've set up two identical reports that is filtered by date and the client
name. I'm using one form to do the filtering.
...
|
by: Richard Hollenbeck |
last post by:
I tried to ask this question before on the 14th of January but I never got a
reply. I'm still struggling with the problem. I'll try to rephrase the
question:
I have a crosstab query with rows...
|
by: mstery |
last post by:
I have a report generated via an ID selection made in a dropdown on a
form. The report filters by an on click event in a preview report
button on the form. Everything in the report, including...
|
by: Gerry Abbott |
last post by:
Hi all.
Im using a form's recordsource for a report. which works fine
Me.RecordSource =
Forms("frmdate01").Form.Controls("HoldLog").Form.Controls("frmHoldLog01").Form.RecordSource
Ive got a...
|
by: |
last post by:
hi,
i have a form on which a user can choose specific criteria such as dates
etc, in order to filter the report that is called from the form.
i do this by using the Where section of the...
|
by: TS |
last post by:
Hi all,
In my windows form, I need the user to select a client name from a combo box
and click on a button that opens another form having CRViewer showing the
data for that client selected.
I...
|
by: paquer |
last post by:
On my Main form I have a Command Button that opens a Subform in order
to create a new Subform record.
At this point I want the subform to show only the new record being
created.
Not all the...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |