Pass strText to Unbound Control.

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

Hi;

When I was new to Access I use to create multiple queries with different
criteria for multiple reports:
qryItemsOnOrder Criteria >0 rptItemsOnOrder
qryItemsInStock Criteria >0 rptItemsInStock

Learned that can use strCriteria and only one qry and only one rpt
Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria

What I need to learn is how to pass "strText" to an Unbound Control in the
Report so that the rpt displays which report the user is viewing.

Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items On Order Report"
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items In Stock Report".

Have tried these and they don't work:
Me.[Reports]![rptItems].[Report]![TextToDisplay] = "ITWORKS"
Me.[Reports].[rptItems].[Report].[TextToDisplay] = "ITWORKS"
Both return: "Can't find the field "!", (exclamation point), referred to in
your extpression."

Me![rptItems].[TextToDisplay] = "ITWORKS"
'Returns: "Can'f find the field "rptItems" referred to in your extpression."

Would someone be so kind as to point me in the right direction.

Thank You.

Andy
 
Just place values you want to display in your report in an unbound control
on a form. Then set the control source of a text box on your report to
something like:

=Forms!frmYourForm!txtYourTextBox
 
Duane;

Thank You for the help.

In the post "Ask for Criteria" You included a link to:
Martin Green's site http://www.fontstuff.com/access/index.htm.

From that page there is a link to:
http://www.fontstuff.com/access/acctut19.htm
which includes exactly what is needed for this database.

"Automate the Report's Title
Most reports need some sort of descriptive title and you might like the
title to change to reflect the records displayed."

He gives this example:
"For each title you need to place an empty control in the report's Report
Header or Report Footer section."
"The text of your title can be made up of plain text ..."
With Reports![rptStaff]
.Filter = strFilter
.FilterOn = True
.txtReportTitle.Value = _
"Staffing Report - " & Format(Date, "dd mmm yyyy")
End With

He doesn't say where in the sequence the "With" should be placed.

Have tried:
Private Sub cmdUnitsOnOrder_Click()

Dim strCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
strCriteria = "[UnitsOnOrder] > 0"

Msg = MsgBox("Do You want to preview the ''Items Ordered'' report
before printing?", vbYesNoCancel)
Select Case Msg
Case vbYes
DoCmd.OpenReport "rptInventory", acPreview, , strCriteria

With Reports![rptInventory]
' .Filter = strFilter
' .FilterOn = True
.txtReportTitle.Value = "Items Ordered Report - " &
Format(Date, "dd mmm yyyy")
End With

Where would the "With.Reports" be placed?

Andy

Duane Hookom said:
Just place values you want to display in your report in an unbound control
on a form. Then set the control source of a text box on your report to
something like:

=Forms!frmYourForm!txtYourTextBox

--
Duane Hookom
MS Access MVP


Andy said:
Hi;

When I was new to Access I use to create multiple queries with different
criteria for multiple reports:
qryItemsOnOrder Criteria >0 rptItemsOnOrder
qryItemsInStock Criteria >0 rptItemsInStock

Learned that can use strCriteria and only one qry and only one rpt
Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria

What I need to learn is how to pass "strText" to an Unbound Control in the
Report so that the rpt displays which report the user is viewing.

Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items On Order Report"
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items In Stock Report".

Have tried these and they don't work:
Me.[Reports]![rptItems].[Report]![TextToDisplay] = "ITWORKS"
Me.[Reports].[rptItems].[Report].[TextToDisplay] = "ITWORKS"
Both return: "Can't find the field "!", (exclamation point), referred to
in
your extpression."

Me![rptItems].[TextToDisplay] = "ITWORKS"
'Returns: "Can'f find the field "rptItems" referred to in your
extpression."

Would someone be so kind as to point me in the right direction.

Thank You.

Andy
 
Looks like your code should work. You didn't what your results are.

Again, I would prefer to send the title in using OpenArgs, reference to a
value in a text box on the form (from the report), or a public variable.

--
Duane Hookom
MS Access MVP


Andy said:
Duane;

Thank You for the help.

In the post "Ask for Criteria" You included a link to:
Martin Green's site http://www.fontstuff.com/access/index.htm.

From that page there is a link to:
http://www.fontstuff.com/access/acctut19.htm
which includes exactly what is needed for this database.

"Automate the Report's Title
Most reports need some sort of descriptive title and you might like the
title to change to reflect the records displayed."

He gives this example:
"For each title you need to place an empty control in the report's Report
Header or Report Footer section."
"The text of your title can be made up of plain text ..."
With Reports![rptStaff]
.Filter = strFilter
.FilterOn = True
.txtReportTitle.Value = _
"Staffing Report - " & Format(Date, "dd mmm yyyy")
End With

He doesn't say where in the sequence the "With" should be placed.

Have tried:
Private Sub cmdUnitsOnOrder_Click()

Dim strCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
strCriteria = "[UnitsOnOrder] > 0"

Msg = MsgBox("Do You want to preview the ''Items Ordered'' report
before printing?", vbYesNoCancel)
Select Case Msg
Case vbYes
DoCmd.OpenReport "rptInventory", acPreview, , strCriteria

With Reports![rptInventory]
' .Filter = strFilter
' .FilterOn = True
.txtReportTitle.Value = "Items Ordered Report - " &
Format(Date, "dd mmm yyyy")
End With

Where would the "With.Reports" be placed?

Andy

Duane Hookom said:
Just place values you want to display in your report in an unbound
control
on a form. Then set the control source of a text box on your report to
something like:

=Forms!frmYourForm!txtYourTextBox

--
Duane Hookom
MS Access MVP


Andy said:
Hi;

When I was new to Access I use to create multiple queries with
different
criteria for multiple reports:
qryItemsOnOrder Criteria >0 rptItemsOnOrder
qryItemsInStock Criteria >0 rptItemsInStock

Learned that can use strCriteria and only one qry and only one rpt
Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria

What I need to learn is how to pass "strText" to an Unbound Control in the
Report so that the rpt displays which report the user is viewing.

Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items On Order Report"
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items In Stock Report".

Have tried these and they don't work:
Me.[Reports]![rptItems].[Report]![TextToDisplay] = "ITWORKS"
Me.[Reports].[rptItems].[Report].[TextToDisplay] = "ITWORKS"
Both return: "Can't find the field "!", (exclamation point), referred to
in
your extpression."

Me![rptItems].[TextToDisplay] = "ITWORKS"
'Returns: "Can'f find the field "rptItems" referred to in your
extpression."

Would someone be so kind as to point me in the right direction.

Thank You.

Andy
 
Duane;

The result doesn't display the desired text.

There aren't any errors, but the unbound text control does not display the
text:
txtReportTitle.Value = "Items Ordered Report - " & Format(Date, "dd mmm
yyyy")

Thank You for Your replies.

Andy

Duane Hookom said:
Looks like your code should work. You didn't what your results are.

Again, I would prefer to send the title in using OpenArgs, reference to a
value in a text box on the form (from the report), or a public variable.

--
Duane Hookom
MS Access MVP


Andy said:
Duane;

Thank You for the help.

In the post "Ask for Criteria" You included a link to:
Martin Green's site http://www.fontstuff.com/access/index.htm.

From that page there is a link to:
http://www.fontstuff.com/access/acctut19.htm
which includes exactly what is needed for this database.

"Automate the Report's Title
Most reports need some sort of descriptive title and you might like the
title to change to reflect the records displayed."

He gives this example:
"For each title you need to place an empty control in the report's Report
Header or Report Footer section."
"The text of your title can be made up of plain text ..."
With Reports![rptStaff]
.Filter = strFilter
.FilterOn = True
.txtReportTitle.Value = _
"Staffing Report - " & Format(Date, "dd mmm yyyy")
End With

He doesn't say where in the sequence the "With" should be placed.

Have tried:
Private Sub cmdUnitsOnOrder_Click()

Dim strCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
strCriteria = "[UnitsOnOrder] > 0"

Msg = MsgBox("Do You want to preview the ''Items Ordered'' report
before printing?", vbYesNoCancel)
Select Case Msg
Case vbYes
DoCmd.OpenReport "rptInventory", acPreview, , strCriteria

With Reports![rptInventory]
' .Filter = strFilter
' .FilterOn = True
.txtReportTitle.Value = "Items Ordered Report - " &
Format(Date, "dd mmm yyyy")
End With

Where would the "With.Reports" be placed?

Andy

Duane Hookom said:
Just place values you want to display in your report in an unbound
control
on a form. Then set the control source of a text box on your report to
something like:

=Forms!frmYourForm!txtYourTextBox

--
Duane Hookom
MS Access MVP


Hi;

When I was new to Access I use to create multiple queries with
different
criteria for multiple reports:
qryItemsOnOrder Criteria >0 rptItemsOnOrder
qryItemsInStock Criteria >0 rptItemsInStock

Learned that can use strCriteria and only one qry and only one rpt
Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria

What I need to learn is how to pass "strText" to an Unbound Control
in
the
Report so that the rpt displays which report the user is viewing.

Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items On Order Report"
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items In Stock Report".

Have tried these and they don't work:
Me.[Reports]![rptItems].[Report]![TextToDisplay] = "ITWORKS"
Me.[Reports].[rptItems].[Report].[TextToDisplay] = "ITWORKS"
Both return: "Can't find the field "!", (exclamation point),
referred
to
in
your extpression."

Me![rptItems].[TextToDisplay] = "ITWORKS"
'Returns: "Can'f find the field "rptItems" referred to in your
extpression."

Would someone be so kind as to point me in the right direction.

Thank You.

Andy
 
Like I stated, I usually pull values into the report rather than attempt to
push them with code from another object (Form).

--
Duane Hookom
MS Access MVP
--

Andy said:
Duane;

The result doesn't display the desired text.

There aren't any errors, but the unbound text control does not display the
text:
txtReportTitle.Value = "Items Ordered Report - " & Format(Date, "dd mmm
yyyy")

Thank You for Your replies.

Andy

Duane Hookom said:
Looks like your code should work. You didn't what your results are.

Again, I would prefer to send the title in using OpenArgs, reference to a
value in a text box on the form (from the report), or a public variable.

--
Duane Hookom
MS Access MVP


Andy said:
Duane;

Thank You for the help.

In the post "Ask for Criteria" You included a link to:
Martin Green's site http://www.fontstuff.com/access/index.htm.

From that page there is a link to:
http://www.fontstuff.com/access/acctut19.htm
which includes exactly what is needed for this database.

"Automate the Report's Title
Most reports need some sort of descriptive title and you might like the
title to change to reflect the records displayed."

He gives this example:
"For each title you need to place an empty control in the report's Report
Header or Report Footer section."
"The text of your title can be made up of plain text ..."
With Reports![rptStaff]
.Filter = strFilter
.FilterOn = True
.txtReportTitle.Value = _
"Staffing Report - " & Format(Date, "dd mmm yyyy")
End With

He doesn't say where in the sequence the "With" should be placed.

Have tried:
Private Sub cmdUnitsOnOrder_Click()

Dim strCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
strCriteria = "[UnitsOnOrder] > 0"

Msg = MsgBox("Do You want to preview the ''Items Ordered''
report
before printing?", vbYesNoCancel)
Select Case Msg
Case vbYes
DoCmd.OpenReport "rptInventory", acPreview, , strCriteria

With Reports![rptInventory]
' .Filter = strFilter
' .FilterOn = True
.txtReportTitle.Value = "Items Ordered Report - " &
Format(Date, "dd mmm yyyy")
End With

Where would the "With.Reports" be placed?

Andy

Just place values you want to display in your report in an unbound
control
on a form. Then set the control source of a text box on your report to
something like:

=Forms!frmYourForm!txtYourTextBox

--
Duane Hookom
MS Access MVP


Hi;

When I was new to Access I use to create multiple queries with
different
criteria for multiple reports:
qryItemsOnOrder Criteria >0 rptItemsOnOrder
qryItemsInStock Criteria >0 rptItemsInStock

Learned that can use strCriteria and only one qry and only one rpt
Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria

What I need to learn is how to pass "strText" to an Unbound Control in
the
Report so that the rpt displays which report the user is viewing.

Dim strCriteria As String
strCriteria = "[ItemsOnOrder] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items On Order Report"
Or
Dim strCriteria As String
strCriteria = "[ItemsInStock] > 0"
DoCmd.OpenReport "rptItems", acPreview, , strCriteria
Me.[Reports].[rptItems].[TextToDisplay] = "Items In Stock
Report".

Have tried these and they don't work:
Me.[Reports]![rptItems].[Report]![TextToDisplay] = "ITWORKS"
Me.[Reports].[rptItems].[Report].[TextToDisplay] = "ITWORKS"
Both return: "Can't find the field "!", (exclamation point), referred
to
in
your extpression."

Me![rptItems].[TextToDisplay] = "ITWORKS"
'Returns: "Can'f find the field "rptItems" referred to in your
extpression."

Would someone be so kind as to point me in the right direction.

Thank You.

Andy
 
Back
Top