Referencing a subform from a module

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Dear all,

I am struggling to reference a subform that sits on a tab
control sitting on a main form. I tried using the
principle of Forms!mainForm!SubformName!ControlName but
this doesn't seem to work. Is it because I need to
reference the tab control within the expression?

Many thanks,

Neil Crawford
 
You should be ok provided that the third element is the
name of the subform control. For example, if your form
'frmMain' had a subForm control 'ctlSub' which had a
textbox 'txtText' the correct syntax would be
Forms!frmMain!ctlSub!txtText
even if ctlSub was in fact the form 'frmSub'

Hope This Helps
Gerald Stanley MCSD
 
Try

Forms!mainForm!SubformControlName.Form!ControlName

SubFormControlName is the name of the control on the main form. It may or may
not be the same name as the form you are using as the basis of the subform.
Access normally uses the name of the form as the name of the subform control,
but that does not HAVE to be the case.
 
John,
either way seems to return the correct value:
Forms!mainForm.Form!SubformName!ControlName , or
Forms!mainForm!SubformControlName.Form!ControlName

Why's that?
Mark
 
John and others,

thanks for the response - my basic error was as John
described - the subformcontrol name was different to the
subform name and I was using the subform name.

Many thanks for your comments,

regards,

Neil
 
Back
Top