简体   繁体   中英

Accessing control in subform from another subform

I have 3 tables (Main, ED, and OP) the relations are Main to ED is 1 to Many Main to OP is 1 to Many

for that I created 3 Forms (frmM, frmE, and frmO)

the frmM has 2 Sub-Forms frmE and frmO (both frmE and frmO are inside frmM data list)

What I want is : once the value of a text-box txtE1 in frmE changes, the text-box txtO1 in frmO will be disabled

I used this code inside frmE

FrmO.txtO1.Enabled = False

although this does not give any error and when debug I can see the value of the text-box changes in the Watch window, yet nothing actually happens to the textbox in the form

I have look at many questions in StackOverFlow and googled for more than 3 days

Requery subform from another subform, problems

http://access.mvps.org/access/forms/frm0031.htm

http://www.dbforums.com/showthread.php?900897-Set-Value-In-A-SubForm

I tried

Forms("frmM")("frmO").Controls("txtO1").Enabled = False
Me.Parent!txtO1.Enabled = False
Forms.frmM.frmO.Form.txtO1.Enabled = False

all of them not working.

anyone can help me here?

Try

Me.Parent!frmO_Container.Form!txtO1.Enabled = False

Where frmO_Container is the name of the subform control on frmM that houses frmO itself

EDIT: and if you aren't already, place this code in the On Change event for txt01

When referring to subforms, it's important to distinguish between the subform control on the parent form, and the subform itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM