Help!

Opening a report only for a specific company

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Reports RSS
Next:  Automatically set screen resolution when opening ..  
Author Message
caro
External


Since: Oct 19, 2009
Posts: 3



PostPosted: Mon Oct 19, 2009 6:44 am    Post subject: Opening a report only for a specific company
Archived from groups: microsoft>public>access>reports (more info?)

I have a report based off a form where many recommendations are listed for
many different companies. Instead of opening the report and seeing all the
recommendations for all companies, I want the user to be able to type in the
company ID immediately and for the report to pull up only records for that
company. I am sure there's an easy way to do this but have completely blanked
here.
Many thanks!
Back to top
Al Campagna
External


Since: Jan 08, 2009
Posts: 27



PostPosted: Mon Oct 19, 2009 9:55 am    Post subject: Re: Opening a report only for a specific company [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

caro,
There are many ways to accomplish that.
One method is to go to the Company record you want to report
on, and run the report from there (leaving the form open). The open form
can provide the report query with the filtering value it needs. You should
use an unique value from your record... such as CompanyID.
You can use this criteria in the report's query... (ex.)
= Forms!YourMainFormName!CompanyID

Or... you can place this criteria in the CompanyID column of your
report query...
=[Enter Company ID]
When the rpeort runs, the query will ask you for a CompanyID.
Enter any legitimate ID, and the report will be filtered by that value.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

"caro" <caro.RemoveThis@discussions.microsoft.com> wrote in message
news:3B1DE130-B1AE-4EFC-AD2F-8B6185BD138C@microsoft.com...
>I have a report based off a form where many recommendations are listed for
> many different companies. Instead of opening the report and seeing all the
> recommendations for all companies, I want the user to be able to type in
> the
> company ID immediately and for the report to pull up only records for that
> company. I am sure there's an easy way to do this but have completely
> blanked
> here.
> Many thanks!
Back to top
Duane Hookom
External


Since: Feb 07, 2005
Posts: 1359



PostPosted: Mon Oct 19, 2009 10:26 am    Post subject: RE: Opening a report only for a specific company [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Take a look at the solution at http://www.mvps.org/access/reports/rpt0002.htm.
--
Duane Hookom
Microsoft Access MVP


"caro" wrote:

> I have a report based off a form where many recommendations are listed for
> many different companies. Instead of opening the report and seeing all the
> recommendations for all companies, I want the user to be able to type in the
> company ID immediately and for the report to pull up only records for that
> company. I am sure there's an easy way to do this but have completely blanked
> here.
> Many thanks!
Back to top
Steve
External


Since: Aug 04, 2009
Posts: 47



PostPosted: Mon Oct 19, 2009 11:16 am    Post subject: Re: Opening a report only for a specific company [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Another way to do it is to put a button on your form and put the following
code in th Click event of the button:

DoCmd.OpenReport "NameOfYourReport",,,"[CustomerID] = " & Me!CustomerID

Steve
santus DeleteThis @penn.com


"caro" <caro DeleteThis @discussions.microsoft.com> wrote in message
news:3B1DE130-B1AE-4EFC-AD2F-8B6185BD138C@microsoft.com...
>I have a report based off a form where many recommendations are listed for
> many different companies. Instead of opening the report and seeing all the
> recommendations for all companies, I want the user to be able to type in
> the
> company ID immediately and for the report to pull up only records for that
> company. I am sure there's an easy way to do this but have completely
> blanked
> here.
> Many thanks!
Back to top
caro
External


Since: Oct 19, 2009
Posts: 3



PostPosted: Mon Oct 19, 2009 11:56 am    Post subject: RE: Opening a report only for a specific company [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I actually do not understand the code that is written in that example at all,
which is probably sad. How would it look if I was allowed to type in the
desired report, and not just look at the last report written?
Thanks,
Caro

"Duane Hookom" wrote:

> Take a look at the solution at http://www.mvps.org/access/reports/rpt0002.htm.
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "caro" wrote:
>
> > I have a report based off a form where many recommendations are listed for
> > many different companies. Instead of opening the report and seeing all the
> > recommendations for all companies, I want the user to be able to type in the
> > company ID immediately and for the report to pull up only records for that
> > company. I am sure there's an easy way to do this but have completely blanked
> > here.
> > Many thanks!
Back to top
caro
External


Since: Oct 19, 2009
Posts: 3



PostPosted: Mon Oct 19, 2009 12:21 pm    Post subject: RE: Opening a report only for a specific company [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

So the expression I am using is:
= DoCmd.OpenReport "Initial CIP-MAA Report", acViewPreview, , "CAGE" = &
CAGE"
The goal is to build an on-open event where a person can type in the CAGE
number to filter the report and to only show that particular report
associated with that CAGE.
Thoughts? Can I do it this way or do I have to use macros?
Thanks,

"Duane Hookom" wrote:

> Take a look at the solution at http://www.mvps.org/access/reports/rpt0002.htm.
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "caro" wrote:
>
> > I have a report based off a form where many recommendations are listed for
> > many different companies. Instead of opening the report and seeing all the
> > recommendations for all companies, I want the user to be able to type in the
> > company ID immediately and for the report to pull up only records for that
> > company. I am sure there's an easy way to do this but have completely blanked
> > here.
> > Many thanks!
Back to top
CraigH
External


Since: Jun 24, 2005
Posts: 7



PostPosted: Mon Oct 19, 2009 12:31 pm    Post subject: RE: Opening a report only for a specific company [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Get the books out and start learning - Also use the help Smile but most of the
advanced things you will want to do will involve understanding VBA. Because
even your what you asked next will require you to understand the coding that
was provided. So I will give you the start...

From the access Web
1 Dim strDocName As String
2 Dim strWhere As String
3 strDocName = "rptSomeReport"
4 strWhere = "[RunID]=" & me!RunID
5 DoCmd.OpenReport strDocName, acPreview, , strWhere

1 and 2 Declare variables used
3 Assignes the name of the report - and if you want the user to be able to
put in the name of the report as you just asked - it could be a textbox on
your form (I would use a combobox but will keep it simple) you would have
strDocName = me.txtReportName
Me refers to the form that you are on the txtReportName is the name of the
textbox on the form
4 For you something like - strWhere = "[CompanyID]=" & me!CompanyID
The [CompanyID]= is the name from your query in the report or table if
based on that - againd the me!companyID - is a combo box or text box on your
form - this is designed to limit it to the company id that you wan't
5 DoCmd.OpenReport strDocName, acPreview, , strWhere this is were you open
the report obviously - you have the document name then opeing it as a preview
instead of sending it straight to the printer then you have a blank variable
USE THE Help if you want to know what this is and then there is the limiting
string.

As stated in the example this code can goes into a command buttton's On
Click Event. (a property under the Event tab for the button - make sure you
use Expression Builder and you can also set this as the default when you
click the elipse (...).

You can even take a shortcut to start you off with using the wizard to put a
button on the form to open a report. This will start you off but then you
need to understand the code to change it to what you want to do.

Hope that gets you started.

Craig



"caro" wrote:

> I actually do not understand the code that is written in that example at all,
> which is probably sad. How would it look if I was allowed to type in the
> desired report, and not just look at the last report written?
> Thanks,
> Caro
>
> "Duane Hookom" wrote:
>
> > Take a look at the solution at http://www.mvps.org/access/reports/rpt0002.htm.
> > --
> > Duane Hookom
> > Microsoft Access MVP
> >
> >
> > "caro" wrote:
> >
> > > I have a report based off a form where many recommendations are listed for
> > > many different companies. Instead of opening the report and seeing all the
> > > recommendations for all companies, I want the user to be able to type in the
> > > company ID immediately and for the report to pull up only records for that
> > > company. I am sure there's an easy way to do this but have completely blanked
> > > here.
> > > Many thanks!
Back to top
Duane Hookom
External


Since: Feb 07, 2005
Posts: 1359



PostPosted: Mon Oct 19, 2009 1:10 pm    Post subject: RE: Opening a report only for a specific company [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Typically you would have a command button to open the report. This can be
created with the command button wizard to write the OpenReport code for you.

Then you should have a cage field value on the form or add a combo box that
allows your cage. Consider naming your combo box "cboCage". Then, modify the
code as per the solution I recommended on the web page resource. Your string
"strWhere" might look like
'assuming the CageField is numeric:
strWhere = "[CageField]=" & Me.cboCage

'If the CageField is Text:
strWhere = "[CageField]=""" & Me.cboCage & """"

--
Duane Hookom
Microsoft Access MVP


"caro" wrote:

> So the expression I am using is:
> = DoCmd.OpenReport "Initial CIP-MAA Report", acViewPreview, , "CAGE" = &
> CAGE"
> The goal is to build an on-open event where a person can type in the CAGE
> number to filter the report and to only show that particular report
> associated with that CAGE.
> Thoughts? Can I do it this way or do I have to use macros?
> Thanks,
>
> "Duane Hookom" wrote:
>
> > Take a look at the solution at http://www.mvps.org/access/reports/rpt0002.htm.
> > --
> > Duane Hookom
> > Microsoft Access MVP
> >
> >
> > "caro" wrote:
> >
> > > I have a report based off a form where many recommendations are listed for
> > > many different companies. Instead of opening the report and seeing all the
> > > recommendations for all companies, I want the user to be able to type in the
> > > company ID immediately and for the report to pull up only records for that
> > > company. I am sure there's an easy way to do this but have completely blanked
> > > here.
> > > Many thanks!
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Reports All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum