How to refrence a textbox in subform (1 Viewer)

Milad

Registered User.
Local time
Today, 06:45
Joined
Jul 8, 2013
Messages
27
I would be thankful if anyone help me reference a text box in sub form. I did the same thing for the combo box in it worked perfect. I am not sure why this is not working for textbox.
This is how I referenced it:
[Forms]![MainOrderForm]![CuttingNumForm].[Form]![Style1]
Form: MainOrderForm
Sub Form: CuttingNumForm
Text Box: Style1
I should also mention that "Style1" filed in automatically once a "CuttingNum" field is selected.

Thanks in advance for your help
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:45
Joined
Feb 19, 2013
Messages
16,685
Where are you referencing from? Another form or report, a query or the main form which hosts the subform?
 

Milad

Registered User.
Local time
Today, 06:45
Joined
Jul 8, 2013
Messages
27
Thanks for your quick response.
I have a form which contains two sub forms. In the first subform I have 4 fields of Cut#, Size, Quantity and Style. Once the cut# is selected, a vba code runs and fill in the rest of fields.
In second sub form I have a field of Fabric# (Combo Box) which should be restricted to the “Style” value on the first sub form. I have a query which contains the Fabric# and Corresponding style and I try to write a vba code to requery once “Style value” changes. I
 

Milad

Registered User.
Local time
Today, 06:45
Joined
Jul 8, 2013
Messages
27
In fact, I want to reference the "Style" field in the query which gives me the "FabricNum"
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:45
Joined
Feb 19, 2013
Messages
16,685
To reference the value in another subform in the same mainform you reference as follows:
Code:
Me.Parent.SubformCtrlName.Form.style1
Note the SubformCtrlName is the name of the control, not the name of the subform used as its source object

For future reference

Me.Parent looks 'up' one level
Me.Parent.Parent looks 'up' two levels etc
 

Milad

Registered User.
Local time
Today, 06:45
Joined
Jul 8, 2013
Messages
27
Thanks. Where should I add this code??
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:45
Joined
Feb 19, 2013
Messages
16,685
In your original post you said

This is how I referenced it:
[Forms]![MainOrderForm]![CuttingNumForm].[Form]![Style1]
so it used where you are currently trying to use the bit I have highlighted in red - basically you are replacing

[Forms]![MainOrderForm]!

with

Me.Parent.
 

Milad

Registered User.
Local time
Today, 06:45
Joined
Jul 8, 2013
Messages
27
Did you mean in the query's criteria? Because that's where I had my previous code.
 

Mr. Ziggins

Registered User.
Local time
Today, 02:45
Joined
Jul 24, 2012
Messages
10
Try this:
on the AfterUpdate() event of the style textbox, put in your event procedure
Code:
[COLOR=#ff0000]Forms!MainOrderForm!CuttingNumForm.Form!Style1.requery[/COLOR]
 

Users who are viewing this thread

Top Bottom