Question about passing form control value to report

dkmoreland

Registered User.
Local time
Today, 05:27
Joined
Dec 6, 2017
Messages
129
To run this report I have, a form will open on which the user will select a start date and an end date, then enter a number that will be used in a calculation on the report. The control is unbound and the value is not stored in any table - it is used for calculation only and is determined by the user.

I know that I can use this as the control's data source

Code:
=[Forms]![Select KPI Date Range]![TxtNumKPINCR]

However, this only works as long as the form is open. How can I pass this to the report if the form is closed? I don't want to leave it open on the screen. I don't think a Where statement will work since there is no table or query behind this control.



Suggestions, please?

Thanks in advance.
 
Save the value using a variable (or a tempvar if you use them)
Reference the variable in the report
 
Save the value using a variable (or a tempvar if you use them)
Reference the variable in the report

Can you give me an example of the DoCmd syntax for referencing that variable?
 
To run this report I have, a form will open on which the user will select a start date and an end date, then enter a number that will be used in a calculation on the report. The control is unbound and the value is not stored in any table - it is used for calculation only and is determined by the user.

I know that I can use this as the control's data source

Code:
=[Forms]![Select KPI Date Range]![TxtNumKPINCR]

However, this only works as long as the form is open. How can I pass this to the report if the form is closed? I don't want to leave it open on the screen. I don't think a Where statement will work since there is no table or query behind this control.



Suggestions, please?

Thanks in advance.
SQL make table. I am not sure if the variable riders discuss will persist. Never tried.

Sent from my SM-G950U using Tapatalk
 
SQL make table. I am not sure if the variable riders discuss will persist. Never tried.

Sent from my SM-G950U using Tapatalk

Why use make table? I don't really need to save this value past the point of generating the report.
 
Why use make table? I don't really need to save this value past the point of generating the report.
Because it cant be lost and it is ez to do.

Sent from my SM-G950U using Tapatalk
 
Repeatedly making tables will bloat your database and is totally unnecessary for this purpose

There are at least 3 ways of transferring the value from form to report
The attached example database demonstrates each of these
1. Get the value of sngValue in the Report load event
2. Add the value as a field in the report record source
3. Set the value using OpenArgs

For simplicity I've used a public or global variable sngValue.
I could have used a tempvar but I tend not to do so

None of the methods use DoCmd code

In each case, the form is closed before the report loads
All work equally well - choose whichever you prefer

HTH
 

Attachments

Last edited:
Repeatedly making tables will bloat your database and is totally unnecessary for this purpose

There are at least 3 ways of transferring the value from form to report
The attached example database demonstrates each of these

For simplicity I've used a public or global variable sngValue.
I could have used a tempvar but I tend not to do so

1. Get the value of sngValue in the Report load event
2. Add the value as a field in the report record source
3. Set the value using OpenArgs

In each case, the form is closed before the report loads
All work equally well - choose whichever you prefer

HTH

I'll give those a try. Thank you!
 

Users who are viewing this thread

Back
Top Bottom