Value on Report from Forms

N

NetworkTrade

Hi,

Have Report built from Table. The Report can be opened from any of several
Forms.

There is a value in an unbound textbox in whichever Form is opened that is
used to open the Report that that value appear on the Report also in a
textbox. Because there are multiple forms I can NOT just put in the Report
TextBox:
Forms!Form1.TextBox

I need a more generic syntax that will be valid for whichever Form is opened
at that moment and that opens the Report (more than one Form will not be
opened at the same time). Can I put something like Me.Textbox ??

thanks
 
D

Duane Hookom

Can you use the where clause in the DoCmd.OpenReport method?

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtBox) Then
strWhere = strWhere & " And [SomeNumericField]=" & Me.txtBox
End If
DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere
 
N

NetworkTrade

will give it a shot in the a.m. thanks for now.
--
NTC


Duane Hookom said:
Can you use the where clause in the DoCmd.OpenReport method?

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtBox) Then
strWhere = strWhere & " And [SomeNumericField]=" & Me.txtBox
End If
DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere


--
Duane Hookom
MS Access MVP

NetworkTrade said:
Hi,

Have Report built from Table. The Report can be opened from any of
several
Forms.

There is a value in an unbound textbox in whichever Form is opened that is
used to open the Report that that value appear on the Report also in a
textbox. Because there are multiple forms I can NOT just put in the
Report
TextBox:
Forms!Form1.TextBox

I need a more generic syntax that will be valid for whichever Form is
opened
at that moment and that opens the Report (more than one Form will not be
opened at the same time). Can I put something like Me.Textbox ??

thanks
 
N

NetworkTrade

looking at your proposal the strWhere statement would be:

strWhere = 1 = 1 And [SomeNumericField] = Me.txtBox

am struggling with this idea. .... = = =

goal of having an unbound field in Form to appear on Report that is opening
; is the [SomeNumericField] the textbox of the Form?

also; am using a button on Form to open Report which triggers Macro that
closes the Form and it Opens the Report using the Where clause available in
Macro design view so that the Report opens to one specific Record....so this
Where clause is already in use in this as well.....

moving some extraneous data (where no Table ) direct from Forms to Report is
turning out to be more complicated than I expected....from one single Form is
a piece of cake - but generically from differing forms to a single report has
me a bit perplexed still.....

--
NTC


Duane Hookom said:
Can you use the where clause in the DoCmd.OpenReport method?

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtBox) Then
strWhere = strWhere & " And [SomeNumericField]=" & Me.txtBox
End If
DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere


--
Duane Hookom
MS Access MVP

NetworkTrade said:
Hi,

Have Report built from Table. The Report can be opened from any of
several
Forms.

There is a value in an unbound textbox in whichever Form is opened that is
used to open the Report that that value appear on the Report also in a
textbox. Because there are multiple forms I can NOT just put in the
Report
TextBox:
Forms!Form1.TextBox

I need a more generic syntax that will be valid for whichever Form is
opened
at that moment and that opens the Report (more than one Form will not be
opened at the same time). Can I put something like Me.Textbox ??

thanks
 
D

Duane Hookom

My understanding was that you wanted to filter a report's record source
based on a value in a text box from several different forms. Is this
correct?

Or, did you simply want a value displayed on a form in a text box also
appear in a text box on the report? This value is apparently not available
in the report's record source.


--
Duane Hookom
MS Access MVP

NetworkTrade said:
looking at your proposal the strWhere statement would be:

strWhere = 1 = 1 And [SomeNumericField] = Me.txtBox

am struggling with this idea. .... = = =

goal of having an unbound field in Form to appear on Report that is
opening
; is the [SomeNumericField] the textbox of the Form?

also; am using a button on Form to open Report which triggers Macro that
closes the Form and it Opens the Report using the Where clause available
in
Macro design view so that the Report opens to one specific Record....so
this
Where clause is already in use in this as well.....

moving some extraneous data (where no Table ) direct from Forms to Report
is
turning out to be more complicated than I expected....from one single Form
is
a piece of cake - but generically from differing forms to a single report
has
me a bit perplexed still.....

--
NTC


Duane Hookom said:
Can you use the where clause in the DoCmd.OpenReport method?

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtBox) Then
strWhere = strWhere & " And [SomeNumericField]=" & Me.txtBox
End If
DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere


--
Duane Hookom
MS Access MVP

NetworkTrade said:
Hi,

Have Report built from Table. The Report can be opened from any of
several
Forms.

There is a value in an unbound textbox in whichever Form is opened that
is
used to open the Report that that value appear on the Report also in a
textbox. Because there are multiple forms I can NOT just put in the
Report
TextBox:
Forms!Form1.TextBox

I need a more generic syntax that will be valid for whichever Form is
opened
at that moment and that opens the Report (more than one Form will not
be
opened at the same time). Can I put something like Me.Textbox
??

thanks
 
N

NetworkTrade

sorry for the lack of clarity - - the latter is the case; there is an
unbound textbox on Form(s) which data is not being recorded into any table -
- - and there was a desire that this info float over to the Report.

So they look at the data on the form. They free form in a comment in a
Form txtBox like "I am ok with this".... and then on the Form they press the
button which generates the Report for printing. This free form comment "I
am ok with this" would like to float over from the form to the report - but
doesn't need to be recorded in table.

1 Form to 1 Report is easy; I could just put in the Report txtBox =
Forms!.Form.Textbox But there is 5 forms that all share the same Report -
so was looking for a generic syntax thinking that since only one form is
opened and it is the form that is launching the report that there was a way
to identify the textbox of the current form i.e. Me ......but this doesn't
seem to work.....
--
NTC


Duane Hookom said:
My understanding was that you wanted to filter a report's record source
based on a value in a text box from several different forms. Is this
correct?

Or, did you simply want a value displayed on a form in a text box also
appear in a text box on the report? This value is apparently not available
in the report's record source.


--
Duane Hookom
MS Access MVP

NetworkTrade said:
looking at your proposal the strWhere statement would be:

strWhere = 1 = 1 And [SomeNumericField] = Me.txtBox

am struggling with this idea. .... = = =

goal of having an unbound field in Form to appear on Report that is
opening
; is the [SomeNumericField] the textbox of the Form?

also; am using a button on Form to open Report which triggers Macro that
closes the Form and it Opens the Report using the Where clause available
in
Macro design view so that the Report opens to one specific Record....so
this
Where clause is already in use in this as well.....

moving some extraneous data (where no Table ) direct from Forms to Report
is
turning out to be more complicated than I expected....from one single Form
is
a piece of cake - but generically from differing forms to a single report
has
me a bit perplexed still.....

--
NTC


Duane Hookom said:
Can you use the where clause in the DoCmd.OpenReport method?

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtBox) Then
strWhere = strWhere & " And [SomeNumericField]=" & Me.txtBox
End If
DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere


--
Duane Hookom
MS Access MVP

Hi,

Have Report built from Table. The Report can be opened from any of
several
Forms.

There is a value in an unbound textbox in whichever Form is opened that
is
used to open the Report that that value appear on the Report also in a
textbox. Because there are multiple forms I can NOT just put in the
Report
TextBox:
Forms!Form1.TextBox

I need a more generic syntax that will be valid for whichever Form is
opened
at that moment and that opens the Report (more than one Form will not
be
opened at the same time). Can I put something like Me.Textbox
??

thanks
 
D

Duane Hookom

One method would be to use the OpenArgs in the DoCmd.OpenReport method. You
could open the report

DoCmd.OpenReport "rptYourReport", acPreview, , , , Me.txtComments

Then in the On Format event of your report that contains the text box, use
something like:

If Len(Me.OpenArgs & "") > 0 Then
Me.txtComments = Me.OpenArgs
End If

I'm not sure which version of Access introduced OpenArgs to reports.

--
Duane Hookom
MS Access MVP

NetworkTrade said:
sorry for the lack of clarity - - the latter is the case; there is an
unbound textbox on Form(s) which data is not being recorded into any
table -
- - and there was a desire that this info float over to the Report.

So they look at the data on the form. They free form in a comment in a
Form txtBox like "I am ok with this".... and then on the Form they press
the
button which generates the Report for printing. This free form comment
"I
am ok with this" would like to float over from the form to the report -
but
doesn't need to be recorded in table.

1 Form to 1 Report is easy; I could just put in the Report txtBox =
Forms!.Form.Textbox But there is 5 forms that all share the same
Report -
so was looking for a generic syntax thinking that since only one form is
opened and it is the form that is launching the report that there was a
way
to identify the textbox of the current form i.e. Me ......but this doesn't
seem to work.....
--
NTC


Duane Hookom said:
My understanding was that you wanted to filter a report's record source
based on a value in a text box from several different forms. Is this
correct?

Or, did you simply want a value displayed on a form in a text box also
appear in a text box on the report? This value is apparently not
available
in the report's record source.


--
Duane Hookom
MS Access MVP

NetworkTrade said:
looking at your proposal the strWhere statement would be:

strWhere = 1 = 1 And [SomeNumericField] = Me.txtBox

am struggling with this idea. .... = = =

goal of having an unbound field in Form to appear on Report that is
opening
; is the [SomeNumericField] the textbox of the Form?

also; am using a button on Form to open Report which triggers Macro
that
closes the Form and it Opens the Report using the Where clause
available
in
Macro design view so that the Report opens to one specific Record....so
this
Where clause is already in use in this as well.....

moving some extraneous data (where no Table ) direct from Forms to
Report
is
turning out to be more complicated than I expected....from one single
Form
is
a piece of cake - but generically from differing forms to a single
report
has
me a bit perplexed still.....

--
NTC


:

Can you use the where clause in the DoCmd.OpenReport method?

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtBox) Then
strWhere = strWhere & " And [SomeNumericField]=" & Me.txtBox
End If
DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere


--
Duane Hookom
MS Access MVP

message
Hi,

Have Report built from Table. The Report can be opened from any of
several
Forms.

There is a value in an unbound textbox in whichever Form is opened
that
is
used to open the Report that that value appear on the Report also in
a
textbox. Because there are multiple forms I can NOT just put in the
Report
TextBox:
Forms!Form1.TextBox

I need a more generic syntax that will be valid for whichever Form
is
opened
at that moment and that opens the Report (more than one Form will
not
be
opened at the same time). Can I put something like Me.Textbox
??

thanks
 

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