Link to home
Start Free TrialLog in
Avatar of didier20
didier20

asked on

Hiding an attachment

I've some trouble to hide an attachment in a database.

The commands (e.g. @IsNotMember("[Finance]";@UserRoles) or
@If(@Name([CN];@UserName) !="xxx yyy" ) are working on a Form but when I use them on Subforms and in Sections they don't seem to work.

I tried it in different way but the only I could do is to hide the whole section. Is there anything that functioning different on Subforms and Sections than on a normal Form?

My goal is with that database to prevent  not Finance users from opening an attachment, but even if I set Default to Author, the user with Author access can't edit other's Forms but they can open the attachment!
SOLUTION
Avatar of madheeswar
madheeswar
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of didier20
didier20

ASKER

Yes, the attachment is in a Rich Text Field.

Where should I enter the lines?
@Command( [RefreshHideFormulas] );
@Command( [SectionExpandAll] );

Querysave, PostSave or Queryclose of the Subforms?

based on your if condition, you can keep it in postopen. Make sure you keep the RTF field in a Section with Hidewhen formulae.
sjef's suggestion is the accepted one.  Basically, the subform loads when the form is opened.  If you want to switch to a hidden attachment subform, or a non-hidden subform, you have to decide this on either the query open or post open event and close and reopen the form to display the correct subform.

Basically, the form will open the default subforms as computed.  If after the document is open, you want to switch subforms, you have to close and reopen.
I don't recommend adding a Hidewhen to a RT field... these cache, and once hidden, it will stay hidden.
It's not an easy job working with RTF fields and hide when options.
You're right the best way is to create a subform (in my case 2 subforms with the option @If(@IsMember("[Finance]";@UserRoles);"RTF";"NonRTF")) and those will do.

I tried it with the Controlled Access Section as well, however it didn't work as expected.

In the above link I read following:
With the header hidden, the user can't open or close the section manually...

But in the properties box I can only hide the title and not header, and
I read too:
If you want to hide based on group or role membership, your formula can just name the  role(s)...

But when I enter [finance] as an Access formula and double click the Section (not in the Designer) a window appears with the following line:

Who may edit the contents of this section. (not from whom is it hidden)
And it shows [finance] what I wrote in the Access formula.
Ok, which do you want?

Rich text >>subforms, only thing that works consistently.  HOWEVER, for the subform to load, it has to load on Open,  so, if you decide that the person should be able to read rich text, you would have to close and reopen the form to load the subform.

-------------------
Sections:  

The formula for the section should be computed-for-display and refer to a computed, or computed-for-display field at the top of the form.
The formula = "[Finance]":"[AnotherRole]"

I don't recall that a section hides any better because you still have to employ the hidewhen on the paragraph.  Once on, you can't take it off.