Passing Variables what am I doing wrong?

G

Guest

I need to pass a variable from my Menu Form to my Working Form but It does
not seem to work.
I have put the following in the "General" section of the Menu Module :-
"Public MenuSelect as Integer", I have set Menuselect to 21 in the Menue
Module Code and then switched to the code in my Working form and tried
"Debug.print "selection = "; MenuSelect. Nothing! Doing the same within the
Menu Form prints selection = 21 in the Immediate window.
I know I can pass OpenArgs when I open a new Form but for various reasons I
open my Forms initially and then make them visible or not as required.
OpenArgs would work first time round in this scenario but would not work
thereafter. Any thoughts please?
Thanks RayC
 
J

Jeff Boyce

Ray

From your description, it sounds like you have set up a variable in one
form, then expected it to appear in another form. Were I working on your
(described) situation, I'd use OpenArgs... after first asking why I felt I
needed to have two forms open...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Hi Jeff
Yes, That is what I was expecting. I thought that a Variable Set as Public
in the General sectionb of a Module would be available to any other module.
Where am I going wrong?
The reason for having mulyiple forms open on the user's machine is that the
Network is not the fastest in the world and in an earlier enquiry if the
MVP's it was suggested that I only open the forms once at the start of a
session and then make them visible or not as the situation demanded.
There must be some other way than using openargs to pass variables between
modules?
Thanks and regards RayC
 
J

Jeff Boyce

Ray

If I'm understanding your description, you set a variable in a FORM's
module, not a general module. What happens in ...<g>

On the other hand, if you want to use multiple forms, all based on the same
underlying ID, you could consider using a main form with a tab control.
Each tab could have a different sub-form feeding it.

Or, if you want a global variable, create one in a general module, then
refer to it/set its value/etc.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Hi Jeff
You ar right, I am trying to set the variable in a Form Module's General
Section, Could you please give me any pointers with regards to a General
Module, where is it, how do I find it, how do I set it up etc.
I am using Tabs but not in the format you suggest and don't think that
basing Tabs on a Sub form wil be suitable but I will look into that.
I will probably go back to opening and closing forms as I go (rather than
opening them and making them visible or not) but your information on my first
point will be very usefull for future knowledge.

Thanks & regards RayC
 
J

Jeff Boyce

From the database window, select the "Modules", create a new one, and add
your Public/Global variable definitions there (a general module, rather than
a Form or Report module).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Hi Jeff
Sorry for comming back to you on this but I have a further Question about
Queries and I am unable open a New Question. The page does nothing when I
click New on the Header(Click or Double Click). I am still able to Post
Replies (as is evidenced by this note). Do you have any idea's?
Thanks Jeff
 
J

Jeff Boyce

Ray

Sounds like me, when I need more caffeine!

I'm not sure what might be happening to prevent you from posting, but if
something like that happens to me, I figure my PC has a "chicken bone stuck
in its throat" and shut it down for a little nap (me, as well as the PC).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top