Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow/prevent editing on a subform

Status
Not open for further replies.

ruru9292

IS-IT--Management
Jan 31, 2005
29
0
0
US
I have master/detail form type. on my detail section I have control tab. on one of these tabs I have the subform.
for simplicity I called the master form x, the control tab y, and subform on tab is z.
I am trying to set the allowedit property to false on the subform if the user who login is not the admin. I have no problem setting the properties allowedits on master form to false, but it does not let me set the allowedits property on the subform. below is the command I am using Onload properties.

if user <> admin then
Form_x.Allowedits = False .....this is works fine
Form_z.AllowEdits = False ..... this is not
else
Form_x.Allowedits = True ..... Works fine
Form_z.AllowEdits = True ..... Nop
endif

Any Ideas
thank you.
 
You may try this:
Form_x!Form_z.Form.AllowEdits = False

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
salam,

you may to write like this :


Me.Form_z.Form.AllowEdits = False

Best rigards
Ali
 
Hello,

I tried all below and all gave compile error data or member not found. the 4th line gave no error but still allow editing.
I also tried to use Onload properties from both x & z forms.

Form_x!Form_z.Form.AllowEdits = False
Me.Form_z.Form.AllowEdits = False
Form_z.Form.AllowEdits = False
Form_z.AllowEdits = False

thanks again.
 
If it is the current form, prefix with the Me keyword

[tt]me.allowedits = <somevalue>[/tt]

If it is another form (not subform), prefix with the collection and the form name, for instance:

[tt]forms!nameofform.allowedits = <somevalue> ' or
forms("nameofform").allowedits = <somevalue>[/tt]

if it is a subform, you need to reference it through the main form on which it resides, and it's the subform control name that's used in the reference, which can be different from the form name as viewed in the database window, perhaps:

[tt]forms!nameofform!nameofsubform.form.allowedits = <somevalue> ' or
forms("nameofform")("nameofsubform").form.allowedits = <somevalue>' or
Me!nameofsubform.form.allowedits = <somevalue> ' or
Me("nameofsubform").form.allowedits = <somevalue>'[/tt]

Easiest way of obtaining the correct reference, in my opinion, is invoking the expression builder, doubleclick through forms, loaded forms, main form, subform and a control on the subform. Strip of the control name, and you should be able to use the resulting reference...

Roy-Vidar
 
I used the expression builder from the main form trying to referece the subform on my tab control, the result is:

[SubformName].Form.AllowEdits

then I used this reference on main form under Onload properties like this:

[FormName].Form.AllowEdits = False ....and also this
Forms![MainFormName]![SubFormName].Form.AllowEdits = False
...but no luck still allowing edits.

I tried also from the subform itself onload properties with
Me.allowedits = false

do you think by puting the subform under the tab control can make a differnce on referencing issue?

thanks



 
Hi,

Let me review and make these replies refresh:

1) If you want to Lock the subform taht don't change at all (even you can not change the record on subform), you should try with these in onopen event on Base form:

Me.Form_z.Enabled = False
Me.Form_z.Locked = True

2) If you want to can add the new record but can not edit the last records you have to make these event on onopen event on your base form:

Me.Form_z.Form.AllowEdits = False

Hope to be clear your requirement
A. Fekri
 
Thanks you all for the details, however; my requirement is that Onload from the main form x, I am calling a function to disable record editing only on my subform zFrm. I tried all the command below with no luck.

Form_z.Form.AllowEdits = False
Form_z.AllowEdits = False
z.Form.AllowEdits = False
Forms![x]![z].Form.AllowEdits = flase

note: if I use Onload from the subform itself the Me.Allowedits works, but when I call the function from the main form it does not.

Please advise.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top