Kath Pelletti
kp at sdsonline.net
Mon Feb 18 18:19:29 CST 2008
Oh....OK. The SecureForm() routine does work with the form object as it a) sets form properties (AllowAdditions / AllowDeletions to false) and then b) cycles thru the controls setting them to disabled/locked etc... How would the SecureSubForm routine need to work if not with the form object? Here is a bit of that SecureForm() code: --------------------------------------- Set frmIn = Forms(strformname) Forms(strformname).Form.AllowDeletions = False Forms(strformname).Form.AllowAdditions = False For Each ctl In frmIn.Controls Select Case ctl.Tag Case "NoLock" 'If ctl.Tag = "NoLock" Then 'If the control has a tag which reads 'NoLock' then it should be visible and enabled (eg. the Close button every form will have this tag). Select Case ctl.ControlType Case acImage ctl.Visible = True ctl.OnClick = "[Event Procedure]" Case acTextBox ctl.Visible = True ctl.Enabled = True ctl.Locked = False Case acComboBox 'ctl.Visible = True ctl.Enabled = True ctl.Locked = False Case acCommandButton ctl.Visible = True ctl.Enabled = True 'ctl.Locked = False Case acCheckBox ctl.Visible = True ctl.Enabled = True ctl.Locked = False End Select 'etc --------------------------------- ----- Original Message ----- From: "Steve Schapel" <miscellany at mvps.org> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Sent: Tuesday, February 19, 2008 11:11 AM Subject: Re: [AccessD] help - syntax for subform > Kath, > > It sorta depends a lot on what the SecureForms() function does. If this > function is working with a Form object, then I think it won't recognise > a subform as a form object no matter what you do to try and fiddle > around with the name. Locking/disabling controls on the subform, which > is being contained within the subform control on the main form, and not > open in its own right, will need to be handled differently by your code. > This may mean a modification/extension to the SecureForm() function, > or the writing of a separate SecureSubform() function. > > Regards > Steve > > > Kath Pelletti wrote: >> 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 >