One parameter, multiple reports

G

Guest

I have a parameter text box (criteria) that I want to pop up when you click
on a command button which asks for input. My problem is, I have 7 reports
that I want to open and print but I don't want the text box to appear for
every report. I want it to ask once and use that criteria for each report.
My code is:

Dim strCBA As String

strCBA = "CBA.CBA = [What do you want to see?]"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , strCBA
DoCmd.OpenReport "Report 1", acViewNormal, , strCBA
DoCmd.SetWarnings True
 
G

Guest

You can either create a text box in a form where the user input the data and
then print the reports, or use inputbox to prompt for the data

Dim strCBA As String , WhereCondition As string

strCBA = InputBox( "What do you want to see?")
WhereCondition = "CBA.CBA = " & strCBA
' If CBA is text field use
WhereCondition = "CBA.CBA = '" & strCBA & "'"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , WhereCondition
DoCmd.OpenReport "Report 1", acViewNormal, , WhereCondition
DoCmd.SetWarnings True
 
G

Guest

Thank you so very much!!!! This worked perfectly.

One other problem that I have been struggling with is, I have a parameter
query that I am using and it has 5 parameter criterias that you can choose
from. I want it so that when they enter one, the remaining text boxes don't
appear, i.e. what CBA, what city, what state. If they choose CBA, no other
boxes come up. Do you need to see the SQL code to know what I am asking??

Ofer Cohen said:
You can either create a text box in a form where the user input the data and
then print the reports, or use inputbox to prompt for the data

Dim strCBA As String , WhereCondition As string

strCBA = InputBox( "What do you want to see?")
WhereCondition = "CBA.CBA = " & strCBA
' If CBA is text field use
WhereCondition = "CBA.CBA = '" & strCBA & "'"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , WhereCondition
DoCmd.OpenReport "Report 1", acViewNormal, , WhereCondition
DoCmd.SetWarnings True
--
Good Luck
BS"D


Diane said:
I have a parameter text box (criteria) that I want to pop up when you click
on a command button which asks for input. My problem is, I have 7 reports
that I want to open and print but I don't want the text box to appear for
every report. I want it to ask once and use that criteria for each report.
My code is:

Dim strCBA As String

strCBA = "CBA.CBA = [What do you want to see?]"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , strCBA
DoCmd.OpenReport "Report 1", acViewNormal, , strCBA
DoCmd.SetWarnings True
 
G

Guest

It's better to create a form with five text box in it where the user can
enter his/her selection, event better if they can select from a combo box.

In the query it will be like

Select * From TableName Where (FieldName1 = Forms![FormName]![TextBox1Name]
Or Forms![FormName]![TextBox1Name] Is Null) And (FieldName2 =
Forms![FormName]![TextBox2Name] Or Forms![FormName]![TextBox2Name] Is Null)

That way it will filter only the text box that has data in them, so the user
can input any filter he/she would like

--
Good Luck
BS"D


Diane said:
Thank you so very much!!!! This worked perfectly.

One other problem that I have been struggling with is, I have a parameter
query that I am using and it has 5 parameter criterias that you can choose
from. I want it so that when they enter one, the remaining text boxes don't
appear, i.e. what CBA, what city, what state. If they choose CBA, no other
boxes come up. Do you need to see the SQL code to know what I am asking??

Ofer Cohen said:
You can either create a text box in a form where the user input the data and
then print the reports, or use inputbox to prompt for the data

Dim strCBA As String , WhereCondition As string

strCBA = InputBox( "What do you want to see?")
WhereCondition = "CBA.CBA = " & strCBA
' If CBA is text field use
WhereCondition = "CBA.CBA = '" & strCBA & "'"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , WhereCondition
DoCmd.OpenReport "Report 1", acViewNormal, , WhereCondition
DoCmd.SetWarnings True
--
Good Luck
BS"D


Diane said:
I have a parameter text box (criteria) that I want to pop up when you click
on a command button which asks for input. My problem is, I have 7 reports
that I want to open and print but I don't want the text box to appear for
every report. I want it to ask once and use that criteria for each report.
My code is:

Dim strCBA As String

strCBA = "CBA.CBA = [What do you want to see?]"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , strCBA
DoCmd.OpenReport "Report 1", acViewNormal, , strCBA
DoCmd.SetWarnings True
 
G

Guest

Thank you again. I will do just that and I will make sure I post that these
solutions that you gave me work PERFECTLY!!!!

Also, can you think of any reason that the form, which is one of the DoCmd
exhibits that I want to produce, will not print out and the form opens up
instead of doing its work in the background. Code:
Dim strCBA As String , WhereCondition As string
I tried DoCmd.PrintOut and creating a macro to make the report print but
nothing. The only thing that happens is the form opens up.

Ofer Cohen said:
It's better to create a form with five text box in it where the user can
enter his/her selection, event better if they can select from a combo box.

In the query it will be like

Select * From TableName Where (FieldName1 = Forms![FormName]![TextBox1Name]
Or Forms![FormName]![TextBox1Name] Is Null) And (FieldName2 =
Forms![FormName]![TextBox2Name] Or Forms![FormName]![TextBox2Name] Is Null)

That way it will filter only the text box that has data in them, so the user
can input any filter he/she would like

--
Good Luck
BS"D


Diane said:
Thank you so very much!!!! This worked perfectly.

One other problem that I have been struggling with is, I have a parameter
query that I am using and it has 5 parameter criterias that you can choose
from. I want it so that when they enter one, the remaining text boxes don't
appear, i.e. what CBA, what city, what state. If they choose CBA, no other
boxes come up. Do you need to see the SQL code to know what I am asking??

Ofer Cohen said:
You can either create a text box in a form where the user input the data and
then print the reports, or use inputbox to prompt for the data

Dim strCBA As String , WhereCondition As string

strCBA = InputBox( "What do you want to see?")
WhereCondition = "CBA.CBA = " & strCBA
' If CBA is text field use
WhereCondition = "CBA.CBA = '" & strCBA & "'"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , WhereCondition
DoCmd.OpenReport "Report 1", acViewNormal, , WhereCondition
DoCmd.SetWarnings True
--
Good Luck
BS"D


:

I have a parameter text box (criteria) that I want to pop up when you click
on a command button which asks for input. My problem is, I have 7 reports
that I want to open and print but I don't want the text box to appear for
every report. I want it to ask once and use that criteria for each report.
My code is:

Dim strCBA As String

strCBA = "CBA.CBA = [What do you want to see?]"
DoCmd.SetWarnings False
DoCmd.OpenReport "Coverpage", acViewNormal, , strCBA
DoCmd.OpenReport "Report 1", acViewNormal, , strCBA
DoCmd.SetWarnings True
 

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