Call subroutine or set property on another form

G

Guest

Hi,

I have a form with a tab control on it, with further forms on two tabs
(Which become subforms of the main form). One of these further forms has a
subform, as follows:

frmMain - Main form
frmTAB1 - Form on first tab page
frmTAB2 - Form on second tab page
frmTAB2sub - Subform on frmTAB2 form

What I need to do is call a subroutine in frmTAB2sub from frmTAB1. It can be
a property let statement even, so long as I can supply 1 variable in the call.

I have spent hours trying to get this to work, and continually run into
syntax / method not available etc... errors. On other forms I can set a
custom property on a subform parent with:

me.parent.propertyname = "Data"

I would have thought:

me.parent.frmTAB2.frmTAB2sub.propertyname = "Data" or

me.parent.frmTAB2.Form.frmTAB2sub.propertyname = "Data"

should work, but doesn't (Including all variations I can think of with .form
used)

Or addressing directly with the likes of:

Forms!frmMain!frmTAB2.Form.frmTAB2sub.propertyname = "Data"

again, including all variations I can think of including .Form!frmTAB2sub...

I even tried creating a property in frmMain which simply passes the value
onto a frmTAB2 property and then passes it onto the final frmTAB2sub. I can
set the frmMain property from frmTAB1, but anything after that causes errors.

The same applies if I try and use the frmTAB2sub routine as a public
subroutine, and try and call it.


Any help is appreciated as I am getting really exasperated.

Thanks in advance.

swas
 
G

Guest

Try something like this:

me.parent.frmTAB2.Form.frmTAB2sub.Form.propertyname = "Data"

You should remember that you are always referring to the subform control,
not the form it contains. In order to do that you need to use SubForm.Form

You should also keep in mind that the names of your subform controls may not
be the same as the name of your subforms themselves (they do not have to be).
If you dragged and dropped them onto your form then they probably match but
it would be worth checking them - it is the subform control names that you
need.

Steve
 
T

tina

yeah, that's a bit convoluted, all right! first, the procedure *does* need
to be declared as Public rather than Private, so it can be used outside the
form it's attached to.

try

Forms!frmMain!frmTAB2.Form!frmTABb2sub.Form.ProcedureName argument

the above goes all on one line regardless of linewrap in this post, of
course.

hth
 
G

Guest

Thanks for the responses, and sorry for taking time to respond.

My problem was deeper than I thought. frmTAB1 actually has a non-Access
control on it (A flexgrid), and my problems were because of this. The routine
was being called in the onload event.

I have been caught out several times before with wierd issues when using
other controls. I just didn't pick it here.

Thanks for the responses.


swas
 

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