Using a Calculated Control in a Report

  • Thread starter Thread starter oldblindpew
  • Start date Start date
O

oldblindpew

I have a report that uses a query for record source, so in my report
procedure I can simply reference the fields by name.

However, one important value is from a calculated text box. I need to use
this value in selecting records for the report, but I don't know how to
reference it from within my procedure. If I had stored it in the table as a
field (e.g. tStatus), I could just reference it by name:

' String for Where Conditions, where Status is in a list of selected values.
Dim strWhereStatusIn As String
strWhereStatusIn = " and tStatus in ("

Instead, I have a text box called txtStatus whose value is calculated via a
public function, with arguments, so the control source for the text box is
like:
= MyFunction([dateArgument])

How can I get my report procedure to know the value of the txtStatus text box?

Thanks,
OldBlindPew
 
Have you tried referring to the control in the form with something like:

Forms!YourFormName!YourControlName

Also, this approach only works if the form is open.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Thanks, Jeff.

Just prior to your reply I discovered a solution in putting a calculated
field in my query. Something like this goes as one of the fields in the
query:

fldStatus: MyFunction([dateArgument])

Then, in the report procedure code:

Dim strWhereStatusIn As String
strWhereStatusIn = " and fldStatus in ("

It seems to be working.

Regards,
Pew

"Give a man a fish and he'll eat for a day; teach him to fish and he'll be a
bum forever!"

Jeff Boyce said:
Have you tried referring to the control in the form with something like:

Forms!YourFormName!YourControlName

Also, this approach only works if the form is open.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

oldblindpew said:
I have a report that uses a query for record source, so in my report
procedure I can simply reference the fields by name.

However, one important value is from a calculated text box. I need to use
this value in selecting records for the report, but I don't know how to
reference it from within my procedure. If I had stored it in the table as
a
field (e.g. tStatus), I could just reference it by name:

' String for Where Conditions, where Status is in a list of selected
values.
Dim strWhereStatusIn As String
strWhereStatusIn = " and tStatus in ("

Instead, I have a text box called txtStatus whose value is calculated via
a
public function, with arguments, so the control source for the text box is
like:
= MyFunction([dateArgument])

How can I get my report procedure to know the value of the txtStatus text
box?

Thanks,
OldBlindPew


.
 
Back
Top