Using variable name in lieu of report name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On Open, my report first opens a form and passes the report name to the form asn OpenArg; also the report has declared a public variable (PhaseChoice) for the value that it is expecting to get back from the form. The form gives the user a combo box to select a phase, and this value is then passed back to the report by setting the public variable as the report's property, like this:

Reports![strReportName].PhaseChoice = Phase.Value

This works fine if instead of strReportName, I have the actual report name, but it doesn't like the variable name. I tested with a Msgbox output that strReportName actually has the report's name, and it does, but I get an error that says there isn't a report called strReportName. I was hoping to reuse this same form for other reports that also require a phase selection, which is why I decided to pass the report name to the form.

Is there a way to do this?
 
Not sure I got the question correctly but try:

Reports(strReportName).PhaseChoice = Phase.Value

--
HTH
Van T. Dinh
MVP (Access)



Clarissa said:
On Open, my report first opens a form and passes the report name to the
form asn OpenArg; also the report has declared a public variable
(PhaseChoice) for the value that it is expecting to get back from the form.
The form gives the user a combo box to select a phase, and this value is
then passed back to the report by setting the public variable as the
report's property, like this:
Reports![strReportName].PhaseChoice = Phase.Value

This works fine if instead of strReportName, I have the actual report
name, but it doesn't like the variable name. I tested with a Msgbox output
that strReportName actually has the report's name, and it does, but I get an
error that says there isn't a report called strReportName. I was hoping to
reuse this same form for other reports that also require a phase selection,
which is why I decided to pass the report name to the form.
 
Sorry if this is a dupe, but I replied several hours ago, and I still don't see it posted:

So, I tried what you said (below), and it worked, sort of. Now, when I select a value in the form, and click OK, after several seconds, I get a dialog box that says "This action will reset the current code in break mode. Do you want to stop the running code?" So, then I click on No, and after a few seconds, the status bar shows that it is running the query (from my report), and then the report finally appears with the data. The end result is what I want, but I think that the users will find the dialog box question confusing. Do you know what it is that's causing that question, and how to avoid it?

Thanks so much for your reply.

----- Van T. Dinh wrote: -----

Not sure I got the question correctly but try:

Reports(strReportName).PhaseChoice = Phase.Value

--
HTH
Van T. Dinh
MVP (Access)



Clarissa said:
On Open, my report first opens a form and passes the report name to the
form asn OpenArg; also the report has declared a public variable
(PhaseChoice) for the value that it is expecting to get back from the form.
The form gives the user a combo box to select a phase, and this value is
then passed back to the report by setting the public variable as the
report's property, like this:
Reports![strReportName].PhaseChoice = Phase.Value
This works fine if instead of strReportName, I have the actual report
name, but it doesn't like the variable name. I tested with a Msgbox output
that strReportName actually has the report's name, and it does, but I get an
error that says there isn't a report called strReportName. I was hoping to
reuse this same form for other reports that also require a phase selection,
which is why I decided to pass the report name to the form.
 
(guessing only): Occasionally when you clear the break points previously
set in Debug mode, the break points look like they have been cleared but
when you run code, the previously cleared breakpoints seem to affect the
code.

Go into any code module, type a few space at the end of a line, move to the
next line, use the menu to clear all break-points, do a Compile then save
the module.

The above steps generally clear the phantom breakpoints in your code.

--
HTH
Van T. Dinh
MVP (Access)




Clarissa said:
Sorry if this is a dupe, but I replied several hours ago, and I still don't see it posted:

So, I tried what you said (below), and it worked, sort of. Now, when I
select a value in the form, and click OK, after several seconds, I get a
dialog box that says "This action will reset the current code in break mode.
Do you want to stop the running code?" So, then I click on No, and after a
few seconds, the status bar shows that it is running the query (from my
report), and then the report finally appears with the data. The end result
is what I want, but I think that the users will find the dialog box question
confusing. Do you know what it is that's causing that question, and how to
avoid it?
 
THANK YOU SO MUCH!!

I had inherited this database and have made a lot of changes, so there was actually a lot of cleaning up to do -- deleting lots of code to be able to compile. But, I still had the problem after your suggestion. However, I did figure it out. The form I was using had this code to close it after passing the value to the report:

DoCmd.close acForm, Me.Name, acSaveN

I cleaned this line up to just: DoCmd.clos

and all works fine now. Thank goodness

Thanks again for all of your help

-Clariss


----- Van T. Dinh wrote: ----

(guessing only): Occasionally when you clear the break points previousl
set in Debug mode, the break points look like they have been cleared bu
when you run code, the previously cleared breakpoints seem to affect th
code

Go into any code module, type a few space at the end of a line, move to th
next line, use the menu to clear all break-points, do a Compile then sav
the module

The above steps generally clear the phantom breakpoints in your code

-
HT
Van T. Din
MVP (Access




Clarissa said:
Sorry if this is a dupe, but I replied several hours ago, and I stil don't see it posted
select a value in the form, and click OK, after several seconds, I get
dialog box that says "This action will reset the current code in break mode
Do you want to stop the running code?" So, then I click on No, and after
few seconds, the status bar shows that it is running the query (from m
report), and then the report finally appears with the data. The end resul
is what I want, but I think that the users will find the dialog box questio
confusing. Do you know what it is that's causing that question, and how t
avoid it
 
Back
Top