I've never passed a variable between forms... this is a first!

misscrf

Registered User.
Local time
Today, 09:45
Joined
Nov 1, 2004
Messages
158
:D
I have a form set up where a user chooses a page tab. Either statistical reports or detail reports. Then they have to choose between 2 toggle buttons. Candidate or hire.

So a user chooses detail, then candidate. An option group below that shows the different groupings of detail candidate reports that they can choose.

A couple of examples - detail report of candidates by office applied to, department, application source etc.

Once that is chosen a button is visible to continue. Now they are taken to the appropriate form. This is done by a global variable gstrformname defined in the afterupdate of the group option that they chose (office etc.)

Once they click to continue to the criteria form, they are choosing the criteria. (for example purposes) the choice below takes the user to a criteria form for choosing an application source ( email, monster.com etc) or click a button and all types are given. I have all of that set up. But now I want to change what report the command button is opening, to a variable. A variable that would be set by the below form when the type of report and grouping for the report are chosen...that defines a certain report.

I specified on this main report menu that it is a candidate report that I want, but when I get to the criteria form, I need a way to pass that choice on. I am not sure how to best do that.

I am trying to avoid making 2 copies of the same form 1 for candidates and 1 for hire. :crazy: I undertstand that I should pass a variable here.

So basically on the main form they choose candidate or hire report, then they choose group. The grouping information tells the command button what form to open (the application source criteria form, the office criteria form, etc). The thing is, this form is the criteria for the candidate report and the hire report. The command button on the criteria form would ideally be -

docmd.previewreport gstrreportname, acpreview

my question is, how or where do I define, from the point that they choose candidate or hire, to the next form, that they want the candidate by office or hire by office report? (define the gstrreportname variable as one of those too.)

Make sense?

Here is a pick of the report form (menu)
reportmenu.jpg



For the afterupdate of the frame for the grouping of the report, I have a select case. In that I define gstrreportname for the report it is, if the choice goes right to a report. If it goes to a form first (for criteria), I define that form with a global variable gstrformname. Can I also define the report there (gstrreportname)? If I do that, will the criteria form know that? Even if I close the main report form?


I hope someone understands me! :shrug:
 
misscrf said:
If it goes to a form first (for criteria), I define that form with a global variable gstrformname. Can I also define the report there (gstrreportname)? If I do that, will the criteria form know that?
:confused: Not entirely sure that I have followed you, but unless you store the information entered in the (criteria) form somehow (either a global variable or table, perhaps) then once the form is closed I think you will loose the information, you would probably have to define the report from the form (and, as long as the first form is open somewhere (minimised/behind the first form), all the information in it will also be available to a query).

BTW, you do know that you don't have to hardcode the report name into the code don't you? You can put the report name into a variable, this would allow you to use the select option or other method to determine and set the report you wish to use, then pass it when the 'View Report' button is clicked. Personnaly I like to pass a report name to a special view report form (which sits on top of a report and has two button on it, 'print' and 'close'), which I find more user friendly than the menu option.

Tim
 
Let me try to explain this again, and maybe my foot won't sit in my mouth, lol.

I have a global variable. I set it (gstrreportname) in the main report form. The issue is that I dont use the variable until I open a form -frmcriteria and make more choices. Then I click a button and need that variable.

It is defined on one form, I need it when I get to the second form. I prefer to open the criteria form and close the first one. This means I need to transfer this variable during the open of the criteria form - help explain better?
I could cry lol.
:( :( :( :( :(
 
Last edited:
a cheap workaround

Hi,

I have a quick and dirty solution for you ... it's not the most elegant solution, but it'lll work.

Make a label on your second form (set it's visible property to false). Attach code to the button on the first form which is in charge of opening the second.
It should be something like


Code:
DoCmd.OpenForm "second form"
[Forms]![second form]![lblInvisibleLabel].Caption = gstrreportname
DoCmd.Close acform, "first form"

This opens your second form, closes your first and makes the variable available on the second form. when you need to use it, just reference it as the caption within the invisible label.

sneaky, I know ... :rolleyes:

-Christina
 
misscrf,

if your variable is global the value of it will be available to all procedures all the time, the only issue is that until you put something in it there won't be anything to take out of it... (unless you set it to null or nothing...)

Tim
 
Thanks, I was able to solve it by passing the variable to the form through openargs

:cool:
 

Users who are viewing this thread

Back
Top Bottom