Full Version: Display Parameter Value on a report
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
Firebott
Hello,

I have a report (r_gender) that asks for a parameter value via a form (f_gender_parm). The query name is q_gender_year.

What I am wanting is to put the parameter value results onto the report. I did do a seach and found a link that someone provided. It is helpful, but I still can't get it to work.

The code that I am putting into the control source of a text box on the report is:
CODE
=[Reports]![r_gender]![startdate]
With this code, it is asking me for another start date

When that did not work I thought maybe I need to reference my parameter form so I tried
CODE
=[forms]![f_gender_parm]![startdate]


Which also did not work.

Once I get this part done, I can wrap up this project. Can anyone help me?

Shauna
dashiellx2000
The second would be the correct method. However, the form needs to be open for this to work. Otherwise, you can use some code if you need to close the form.

HTH.
Firebott
Here is the code that I have in the report.

CODE
Option Compare Database
Option Explicit
Private Sub Report_Close()
   DoCmd.Close acForm, "f_Gender_Parm"
End Sub

Private Sub Report_Open(Cancel As Integer)
   'Set public variable to true to indicate that the report is in the open event
bInReportOpenEvent = True

   'Open the Parameter Form
DoCmd.OpenForm "f_Gender_Parm", , , , , acDialog
  
   'Cancel report if User click the cancel button
If IsLoaded("f_Gender_Parm") = False Then Cancel = True

   'Set public variable to false to indicate that the open event is completed
bInReportOpenEvent = False

End Sub


Doesn't this keep the form open until the report is closed? I did not write this code, I got it from UA
freakazeud
Hi,
you are opening a dialog form which will always be on top until you are closing it. So you would probably want to hide it instead of close it. Use its visible property on the button that you are using on the dialog form. Then on the close event of the report itself actually close the form.
HTH
Good luck
dashiellx2000
Personally, I would go about this an entirely different way (this is not to say that the method you are using is not valid, just that I have a way I prefer).

When the user wants to open the report, I'm assuming on a button click, rather then open the report first, open the Form first. Have the user enter their parameter and then on a button click, open the form. Remove the Report_Open code from your report. You can keep the Report Close code.

HTH.
Firebott
Bill,

I adjusted the code and events to reflect your advice but when I go to run the report I get a parameter value question for [startdate]. I have attached a copy of the database with bogus data. I set the parameter form to run from the reports page (command button) then run the report. Not sure what I have done wrong. But once again this will be a learning tool

Shauna
Firebott
Bill,

Disregard my previous post I realized what was wrong and got it working. I forgot to change my text box located on my report to =[Forms]![f_gender_parm]![startdate].

Thanks for your help
dashiellx2000
Glad you worked it out.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.