Global Variable

DCinFRANCE

Registered User.
Local time
Today, 11:15
Joined
Oct 21, 2017
Messages
21
It may sound redundant, but I appreciate anyone's time to answer.

Is there any way to create "global" variables such that two independent forms, both in memory, can share their values?
 
if you are using same table or Queries with
same source table, you don't need Public variables.
the textbox which is bound to the field is refreshed automatically.
 
If you are just asking how to define a variable globally, just type something like this in a standard module

Code:
Global strText as String

or

Code:
Public strText as String

If you want a value available then

Code:
Const strText = "ridders"
 
I never seem to ask my question specific enough.

First, no code. I know how to declare variables, but there is no VBA, and can't be. I've explained elsewhere, but I will add to that that I don't want to spend the next 3 months becoming a coder. This is not even close to what I do for a living.

Second, I mentioned two independent forms. I know the syntax within the form/subform(s) and do it frequently. This is across open forms. Form A sets a value, and form B can use it.
 
No code, no possible.
 
if you are using same table or Queries with
same source table, you don't need Public variables.
the textbox which is bound to the field is refreshed automatically.

Ariel has already pointed you in the right direction, just store the value in its own table...
 
If you are just using macros use SetTempVar ?
 
Sigh. Not really.

As for coding, and employing a coder (programmer), that was the whole point -- that no, it would not require an arm and leg and months of development. The use of macros is a necessary evil...and the way Access builds them, they are simple and not nearly rising to the level of coding. Of the macros I've had to "write" myself, not more than a few lines have been necessary.

Thanks Gasman. I looked at that, and it remains an option, but being the newbie that I am, I didn't think that would fit my criteria either. I thought it could be as simple as creating a field in form A, and referring to it as [Forms]![Form A]![varname] in form B, but no biscuit. So, each form gets a combobox and I chose what I want in each. So be it.
 
You can easily do that with the Builder

= Forms![frmtest]![Prodavac]

However the form would have to be open for it to work?

Sigh. Not really.

As for coding, and employing a coder (programmer), that was the whole point -- that no, it would not require an arm and leg and months of development. The use of macros is a necessary evil...and the way Access builds them, they are simple and not nearly rising to the level of coding. Of the macros I've had to "write" myself, not more than a few lines have been necessary.

Thanks Gasman. I looked at that, and it remains an option, but being the newbie that I am, I didn't think that would fit my criteria either. I thought it could be as simple as creating a field in form A, and referring to it as [Forms]![Form A]![varname] in form B, but no biscuit. So, each form gets a combobox and I chose what I want in each. So be it.
 
What about a hidden form? I think you could reference controls on that from other forms.
 
Yeah, Gasman, I tried it. I too assumed that "Form A" and "Form B" had to be open for B to "see" A. Double checked all references, and they were correct and specific to the form. I didn't get an error; just the display of Null (or "") in the field.

Yeah, Giz, I thought that too. I investigated some after it was mentioned. Trouble is, I need the object's value from Form A to get into the macro, and that does not appear possible.

It's pretty clear that the only way to do what I had in mind is though code as opposed to macro. Form data is public on to itself; that is, the form and any subforms within, and macros are more or less blind to form data.

:banghead:

However, thank you all for your efforts.
 
You say you checked the references?
If you use the Builder the references should be correct.No chance of misspelling etc.

However you would need to refresh form B to take into account when Form A changes, and hence code
 

Attachments

I am somewhat baffled by the reluctance to use a few lines of code to achieve what you want. A macro is just really a simplified code builder.

Even if you only use the code to achieve this one part and use macro's elsewhere.

If you want to jump through the hoops then either use Arne suggestion - a table with your Global variables, or a hidden permanently open form with a loads of text boxes.

The latter would be clunky, but would fit your slightly odd remit.
 

Users who are viewing this thread

Back
Top Bottom