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!

Prevent records from editing

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

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.
 
ruru9292,

Here..

The issue is that the subform is not really a form, but a control that appears on a main form. Refer to the subform as a control, rather than as a form, with the following syntax:

Code:
Forms![main form name]![subform control name].Form![control name]

I hope this helps...

[thumbsup2]



 
Master form name is : Xfrm
Subform name is : Yfrm

I tried to follow the rules above as stated below, but no luck. what I am doing wrong?

Forms![Xfrm]![Yfrm].Form.AllowEdits = False

please advise.
thanks


 

Try the Me method.

Make sure that subfName is the name of the subform control on the mainform. Click once on the subform then check the Name property which is found under the 'Other' tab in the property sheet. Whatever you find there should be used in place of 'subfName' in the code below.

Code:
Me![subfName].form.AllowEdits = False


Good Luck..




 
I used the expression builder from the main form trying to referecce 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:

[SubFormName].Form.AllowEdits = False ....and also tried
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 ...but no luck

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

thanks
 

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

What??? Is the subform on a tab control? If it is then the answer is a resounding yes!

Also did you read my previous post? What is the name of the property??


 

Thanks for the details, however; 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.

my requirement is that Onload from the main form x, I am calling a global function to disable record editing only on my subform z. 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 = False

x = mainform name
z = subform name

Please advise
 


HitechUser said:
Make sure that subfName is the name of the subform control on the mainform. Click once on the subform then check the Name property which is found under the 'Other' tab in the property sheet. Whatever you find there should be used in place of 'subfName' in the code below.

Have you done this???

Please verify the name of the control...

Good Luck...


 

It IS possible for the subform control name to be different than the subform name in the form view....

As I stated before (see my last post) you need to verify the names.

If I still do not make sense, then Please, Please review Roy's repsonse post here Tek-Tips


Good Luck...


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top