[AccessD] help - syntax for subform

McGillivray, Don [IT] Donald.A.McGillivray at sprint.com
Mon Feb 18 18:38:06 CST 2008


Hi Kath,

I don't know how you would refer to the subform within a main form without the name of the subform as it appears in the main form.  (Try saying that three times really fast . . .)  I made a quick bit of code that accepts the main form's name along with the subform's name as an optional argument.  The code was able to enumerate the controls on the subform.  The values were fed to the proc by the OnLoad event of the subform as the main form opened.  I used Me.Parent.Name to supply the main form's name, and a hard-coded value for the main form's subform control name.  (Dunno how else you'd deliver the name of the main form's subform control unless it was the same as the subform itself, in which case you could use Me.Name, I guess.)  The proc used the following syntax to access the subform's controls"

Forms(MainFormName).Controls(SubformName).Form.Controls

Hope this helps

Don

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti
Sent: Monday, February 18, 2008 3:26 PM
To: Access D Normal List
Subject: [AccessD] help - syntax for subform

Can anyone help with syntax needed here.....

I have been working on a routine called SecureForm() which locks/disable controls for any form which is passed to it.

The routine is called on each form's 'On Load' event and works fine for main forms by passing the 'me.name' string.

I now need to add code to the OnLoad of the subforms as well .....so I need to pass it the FULL name of the subform (including the full reference to the parent name), not just the name of the subform itself.

I have been mucking around with the parent property with no luck so in the code below I am trying to get around the error by actually typing in the name of the subform but even that is giving me the same error.


------------------------------
Code is:

    'Call SecureForm function which locks controls, depending on which user group is logged in.
    'strformname = Me.Name            'this works for main forms but not subforms
    strformname = "Forms!FrmPersonDetails!FrmSubformPeopleatWorkplace"

    Call SecureForm(strformname)
----------------------------------------

Kath

______________________________________
Kath Pelletti
Software Design and Solutions Pty Ltd
Ph: 9505-6714
Fax: 9505-6430
kp at sdsonline.net
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list