Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sooo confused.

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
I inherited a program that was running very very slow 2-3 minutes on opening one form.
The designer had a form with a combobox to select the permitno. From there, it passed the value to another form (permitinfo).
This form had a subform (meterinfo).

What I did.

I moved the combo box to the header of a new form. Then made the original permitinfo form a subform by itself.
so I ended up with
[tab][tab][tab] [tab][tab][tab] [tab][tab][tab] [tab][tab][tab] [tab][tab][tab] has control
Mainform: FrmMeterReturn_main [tab] [tab] [tab] cbopermitno
Subform1: subMeterReturn_PermitInfo[tab] [tab] [tab]txtPmtThousands
Subform2: subMeterReturn_MeterInfo[tab] [tab] [tab]RcvdRdg

On the subform2, RcvdRdg after update property I am trying to recalc the txtPmtThousands. I keep getting hung up on the correct syntax for that referencing txtPmtThousands field.
This is what I've tried so far but keep getting the error message that it can't find the control.
Code:
txtInThousands = vTotGalsThousands  (global variable which does keep the value)

 ' Forms!FrmMeterReturn_Main!txtPmtThousands = Me![txtInThousands]
' Me.subMeterReturn_PermitInfo!txtPmtThousands = Me![txtInThousands]
'[Forms]![FrmMeterReturn_Main]![txtPmtThousands] = Me![txtInThousands]
'Forms![frmMeterReturn_Permitinfo]![txtPmtThousands] = Me![txtInThousands]
'Forms!FrmMeterReturn_Main!frmMeterReturn_permitinfo.Form!txtPmtThousands = Me![txtInThousands]

'Me.FrmMeterReturn_Main!txtPmtThousands = Me![txtInThousands]
' Me.Parent!txtPmtThousands = Me![txtInThousands]
'Me.Parent.Parent!txtPmtThousands = Me![txtInThousands]
'Forms!FrmMeterReturn_Main!Form!txtPmtThousands = Me![txtInThousands]
Forms!FrmMeterReturn_Main!txtPmtThousands = vTotGalsThousands
Forms!FrmMeterReturn_Main!Form!txtPmtThousands = Me![txtInThousands]

I read the chart that was referenced on another thread but guess I'm not really reading it correctly.
I thought that I needed to reference. MainformName.SubformName.SubformControlName but clearly this isn't working.
Can anyone see what I'm doing wrong?
 
If you are calling it from the mainForm then you can use
Me.SubformControlName.Form.ControlOnSubFormName

Me.SubformControlName returns the subform control. You have to then add the word "Form" to return the form inside the subform control

 
I'm on subform2 not the mainform when I'm calling it. Should I set focus to the combobox (only control on mainform) and then use your statement?
 
So if you want to reference a control on the Main form or another subform, but calling the code from a subform.

Calling a control on the Main Form from subform1
Me.Parent.ControlNameOnParentForm

Calling a control on subform2 calling it from subform1
Me.Parent.Subform2ControlName.Form.ControlOnSubForm2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top