[AccessD] help - syntax for subform

Dan Waters dwaters at usinternet.com
Mon Feb 18 18:38:29 CST 2008


Try this syntax instead:

Forms("frmPersonDetails").FrmSubformPeopleatWorkplace.Form.Name

But I think it's the same.



Also, 'Set frmIn = Forms(strformname)' will NOT work for a subform that is
loaded in a subform control in an open main form.  

Try something like this:

--------------------------------------
  Dim frm as form

  frm = Forms("frmPersonDetails").FrmSubformPeopleatWorkplace.Form

  Call SecureForm(frm)

---------------------------------------

Public Sub SecureForm(frmSecure as Form)

  frmSecure.AllowDeletions = False 
  frmSecure.AllowAdditions = False

  For Each ctl in frmSecure.Controls

----------------------------------------

What the above is doing is passing a reference to the form in the subform
control, not the name of the form, to your SecureForm procedure.

Hope THIS Helps!
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti
Sent: Monday, February 18, 2008 6:14 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] help - syntax for subform

Thanks Darren/Dan.

No luck yet....this code (Dan's version) :

    strformname = 
Forms("frmPersonDetails")("FrmSubformPeopleatWorkplace").Form.Name
    gives me error 'Can't find the field 'FrmSubformPeoplatWorkplace' 
referred to in your expression:

and this code (Darren version) gives me error:
    strformname = "Forms!FrmPersonDetails.form.FrmSubformPeopleatWorkplace"
    "Can't find the form 
'Forms!frmpersondetails.form.frmSubformPeopleatWorkplace' referred to in 
your experssion.

aaarrgghh....yes, I want to make the code more generic but once I get a 
version which works I will convert it.......

Kath


----- Original Message ----- 
From: "Dan Waters" <dwaters at usinternet.com>
To: "'Access Developers discussion and problem solving'" 
<accessd at databaseadvisors.com>
Sent: Tuesday, February 19, 2008 10:45 AM
Subject: Re: [AccessD] help - syntax for subform


> Try this:
>
> strFormName = Forms("frmPersonDetails")("subPeopleAtWork").Form.Name
>
> In this example 'frmPersonDetails' is the main form.
>
> And subPeopleAtWork is the subform control (not the form).
>
> And .Form is the form within the subform control.
>
> And .Name is the name of the form in the subform control.
>
> HTH!
> Dan
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti
> Sent: Monday, February 18, 2008 5: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
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 


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