Selection Criteria for Report without Query

S

spacerocket

Hello,

I created a report called Report_Customer which shows all customers and
their details. I want to allow user to select which Customer to display in
the report, so I created a form called Form_SelectCust. This form contains a
combo box that lists out all customers, cbxCust, and a button to preview
report.

I've seen many examples in MS Assistance, but they all have a Query. Is it
possible that query is not used, instead, when user click on preview report,
the Report_Customer is displayed, and only shows the select Customer from
cbxCust?

If yes, how do I do that?

Thanks in advance.
 
A

Allen Browne

Yes, you can do that by using the WhereCondition of the OpenReport to
retrict it to just one customer.

For a basic example of doing this, see:
Print the record in the form
at:
http://members.iinet.net.au/~allenbrowne/casu-15.html

In your case the WhereCondition string will end up looking something like
this:
"[CustomerID] = " & [cbxCust]
assuming that CustomerID is a Number field (not a Text field).


BTW, using "Report_" as a prefix for the name of your report is not a good
idea. Access uses that prefix to refer to the module of the report, as you
can see in the Title bar of the code window if you view the code of a
report. Most of us use the "rpt" prefix.
 
S

spacerocket

Hi,

I tested your code and it works! Thanks. And I have changed all the names
with the prefix Report_ to Rpt.

I have another question, what is the difference in terms of using report
straight away from a form, and using query to create a report? Will it reduce
some database size?

I plan to include BeginDate and EndDate as there is another field TransDate
that I would like to have as selection criteria. Will it work if I just add
the codes into the Print button?

Allen Browne said:
Yes, you can do that by using the WhereCondition of the OpenReport to
retrict it to just one customer.

For a basic example of doing this, see:
Print the record in the form
at:
http://members.iinet.net.au/~allenbrowne/casu-15.html

In your case the WhereCondition string will end up looking something like
this:
"[CustomerID] = " & [cbxCust]
assuming that CustomerID is a Number field (not a Text field).


BTW, using "Report_" as a prefix for the name of your report is not a good
idea. Access uses that prefix to refer to the module of the report, as you
can see in the Title bar of the code window if you view the code of a
report. Most of us use the "rpt" prefix.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

spacerocket said:
Hello,

I created a report called Report_Customer which shows all customers and
their details. I want to allow user to select which Customer to display in
the report, so I created a form called Form_SelectCust. This form contains
a
combo box that lists out all customers, cbxCust, and a button to preview
report.

I've seen many examples in MS Assistance, but they all have a Query. Is it
possible that query is not used, instead, when user click on preview
report,
the Report_Customer is displayed, and only shows the select Customer from
cbxCust?

If yes, how do I do that?

Thanks in advance.
 
A

Allen Browne

It does not matter whether the RecordSource of your report is a table, a
query, or a SQL statement. Whatever is most appropriate. There is no
significant difference in the database size.

For an example of using a WhereConditon to open a report based on a
BeginDate and EndDate, see:
Limiting a Report to a Date Range
at:
http://members.iinet.net.au/~allenbrowne/casu-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

spacerocket said:
I tested your code and it works! Thanks. And I have changed all the names
with the prefix Report_ to Rpt.

I have another question, what is the difference in terms of using report
straight away from a form, and using query to create a report? Will it
reduce
some database size?

I plan to include BeginDate and EndDate as there is another field
TransDate
that I would like to have as selection criteria. Will it work if I just
add
the codes into the Print button?

Allen Browne said:
Yes, you can do that by using the WhereCondition of the OpenReport to
retrict it to just one customer.

For a basic example of doing this, see:
Print the record in the form
at:
http://members.iinet.net.au/~allenbrowne/casu-15.html

In your case the WhereCondition string will end up looking something like
this:
"[CustomerID] = " & [cbxCust]
assuming that CustomerID is a Number field (not a Text field).


BTW, using "Report_" as a prefix for the name of your report is not a
good
idea. Access uses that prefix to refer to the module of the report, as
you
can see in the Title bar of the code window if you view the code of a
report. Most of us use the "rpt" prefix.


spacerocket said:
Hello,

I created a report called Report_Customer which shows all customers and
their details. I want to allow user to select which Customer to display
in
the report, so I created a form called Form_SelectCust. This form
contains
a
combo box that lists out all customers, cbxCust, and a button to
preview
report.

I've seen many examples in MS Assistance, but they all have a Query. Is
it
possible that query is not used, instead, when user click on preview
report,
the Report_Customer is displayed, and only shows the select Customer
from
cbxCust?

If yes, how do I do that?

Thanks in advance.
 
T

TxBlueEyes

Hi There Allen, I have one other component I'd like to add to the code, but I
wasn't really sure where in the code I could add it... It's a Combo box on
the frmWhatDates form (or is this something that can't be done?) that would
also allow the user to select the Team Lead as well as the txtStartDate and
the txtEndDate.... here's the code I want to add to your code:
WhereCondition:="[TEAM LEAD]= '" & Me.cboteamlead _
& "'
Any assistance you can provide would be greatly appreciated... TRB
It does not matter whether the RecordSource of your report is a table, a
query, or a SQL statement. Whatever is most appropriate. There is no
significant difference in the database size.

For an example of using a WhereConditon to open a report based on a
BeginDate and EndDate, see:
Limiting a Report to a Date Range
at:
http://members.iinet.net.au/~allenbrowne/casu-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

spacerocket said:
I tested your code and it works! Thanks. And I have changed all the names
with the prefix Report_ to Rpt.

I have another question, what is the difference in terms of using report
straight away from a form, and using query to create a report? Will it
reduce
some database size?

I plan to include BeginDate and EndDate as there is another field
TransDate
that I would like to have as selection criteria. Will it work if I just
add
the codes into the Print button?

Allen Browne said:
Yes, you can do that by using the WhereCondition of the OpenReport to
retrict it to just one customer.

For a basic example of doing this, see:
Print the record in the form
at:
http://members.iinet.net.au/~allenbrowne/casu-15.html

In your case the WhereCondition string will end up looking something like
this:
"[CustomerID] = " & [cbxCust]
assuming that CustomerID is a Number field (not a Text field).


BTW, using "Report_" as a prefix for the name of your report is not a
good
idea. Access uses that prefix to refer to the module of the report, as
you
can see in the Title bar of the code window if you view the code of a
report. Most of us use the "rpt" prefix.


Hello,

I created a report called Report_Customer which shows all customers and
their details. I want to allow user to select which Customer to display
in
the report, so I created a form called Form_SelectCust. This form
contains
a
combo box that lists out all customers, cbxCust, and a button to
preview
report.

I've seen many examples in MS Assistance, but they all have a Query. Is
it
possible that query is not used, instead, when user click on preview
report,
the Report_Customer is displayed, and only shows the select Customer
from
cbxCust?

If yes, how do I do that?

Thanks in advance.
 
T

TxBlueEyes

Never mind Allen, I was able to figure it how to add my coder to your code,
and it works great... ;o)

TxBlueEyes said:
Hi There Allen, I have one other component I'd like to add to the code, but I
wasn't really sure where in the code I could add it... It's a Combo box on
the frmWhatDates form (or is this something that can't be done?) that would
also allow the user to select the Team Lead as well as the txtStartDate and
the txtEndDate.... here's the code I want to add to your code:
WhereCondition:="[TEAM LEAD]= '" & Me.cboteamlead _
& "'
Any assistance you can provide would be greatly appreciated... TRB
It does not matter whether the RecordSource of your report is a table, a
query, or a SQL statement. Whatever is most appropriate. There is no
significant difference in the database size.

For an example of using a WhereConditon to open a report based on a
BeginDate and EndDate, see:
Limiting a Report to a Date Range
at:
http://members.iinet.net.au/~allenbrowne/casu-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

spacerocket said:
I tested your code and it works! Thanks. And I have changed all the names
with the prefix Report_ to Rpt.

I have another question, what is the difference in terms of using report
straight away from a form, and using query to create a report? Will it
reduce
some database size?

I plan to include BeginDate and EndDate as there is another field
TransDate
that I would like to have as selection criteria. Will it work if I just
add
the codes into the Print button?

:

Yes, you can do that by using the WhereCondition of the OpenReport to
retrict it to just one customer.

For a basic example of doing this, see:
Print the record in the form
at:
http://members.iinet.net.au/~allenbrowne/casu-15.html

In your case the WhereCondition string will end up looking something like
this:
"[CustomerID] = " & [cbxCust]
assuming that CustomerID is a Number field (not a Text field).


BTW, using "Report_" as a prefix for the name of your report is not a
good
idea. Access uses that prefix to refer to the module of the report, as
you
can see in the Title bar of the code window if you view the code of a
report. Most of us use the "rpt" prefix.


Hello,

I created a report called Report_Customer which shows all customers and
their details. I want to allow user to select which Customer to display
in
the report, so I created a form called Form_SelectCust. This form
contains
a
combo box that lists out all customers, cbxCust, and a button to
preview
report.

I've seen many examples in MS Assistance, but they all have a Query. Is
it
possible that query is not used, instead, when user click on preview
report,
the Report_Customer is displayed, and only shows the select Customer
from
cbxCust?

If yes, how do I do that?

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top