Referencing a subform from a module

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
 
G

Gerald Stanley

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
 
J

John Spencer (MVP)

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.
 
F

FPS, Romney

John,
either way seems to return the correct value:
Forms!mainForm.Form!SubformName!ControlName , or
Forms!mainForm!SubformControlName.Form!ControlName

Why's that?
Mark
 
N

Neil

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top