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 1900
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: 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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |