Hi Guys,
I've spent hours trying to figure this out but just can't crack it.
Here is a simplified explanation:
I have a form (Form1) that has a tab control that has a number of Sub forms called subform1, subform2, subform3 etc. On subform1 there are text boxes called "TextBox1", TextBox2", "TextBox3" and "PartName"..
When TextBox1 is clicked, another form (Form2) is displayed.
As I am using Global variables to pass values between the forms (as this makes it easy for me to utilise this functionality throughout the application), when TextBox1 is clicked, the OnClick event sets the global variable called GBL_PartName = Me.[PartName] on subform1.
All of this works great.
On Form2 I have a textbox called "txtPartName".
I want to pass the Global variable, GBL_PartName to this textbox so that it is displayed on Form2.....
I though that I could simply do the following in the Control source of "txtPartName":
=GBL_PartName
But it doesn't like it.
I tried setting it via VBA in the On Current event when Form2 opens but that doesn't work either.
I also tried to get the PartName direct from form 1 by using the following in the control source of "txtPartName":
=Forms("Form1").[subform1].[Form].[PartName]
The above works but it causes me issues in that it makes it more difficult to reuse the functionality across different parts of the application.
Ok, so here are my questions:
1. how do I specify a Global variable as the Control source for my text box either via VBA or direct?
2. Is if possible to directly set the Control Source of the text box to pick the PartName from the Active form???
Thanks for your help with this as its giving me headaches!
Cheers
Greg
I've spent hours trying to figure this out but just can't crack it.
Here is a simplified explanation:
I have a form (Form1) that has a tab control that has a number of Sub forms called subform1, subform2, subform3 etc. On subform1 there are text boxes called "TextBox1", TextBox2", "TextBox3" and "PartName"..
When TextBox1 is clicked, another form (Form2) is displayed.
As I am using Global variables to pass values between the forms (as this makes it easy for me to utilise this functionality throughout the application), when TextBox1 is clicked, the OnClick event sets the global variable called GBL_PartName = Me.[PartName] on subform1.
All of this works great.
On Form2 I have a textbox called "txtPartName".
I want to pass the Global variable, GBL_PartName to this textbox so that it is displayed on Form2.....
I though that I could simply do the following in the Control source of "txtPartName":
=GBL_PartName
But it doesn't like it.
I tried setting it via VBA in the On Current event when Form2 opens but that doesn't work either.
I also tried to get the PartName direct from form 1 by using the following in the control source of "txtPartName":
=Forms("Form1").[subform1].[Form].[PartName]
The above works but it causes me issues in that it makes it more difficult to reuse the functionality across different parts of the application.
Ok, so here are my questions:
1. how do I specify a Global variable as the Control source for my text box either via VBA or direct?
2. Is if possible to directly set the Control Source of the text box to pick the PartName from the Active form???
Thanks for your help with this as its giving me headaches!
Cheers
Greg