|
Form and Report Open Arguments Posted: 04 Feb 2010 11:25 PM PST While opening a Report or Form we can pass several Optional Values as Run-Time Arguments to control the output on the Report or to change the Form Open Mode depending on the User's Profile. For example: If the Current User belongs to a particular Users Group, in the Security Workgroups, who has only enough privilege to view the data and not to Add or Edit then we can open the Form in Read-only mode otherwise in Normal Mode, when the Current User attempts to open the Form. The following Code checks whether the Current User belongs to a particular User Group. The following Code of CheckGroup() Function must be copied into a Standard Module in your Database.
The CheckGroup() Function must be called from a Command Button Click Event Procedure (we will do this at the end of this Article) as shown below to check and returns the User Group Name to open the Form in a particular Mode.
The CheckGroup() program creates an Array of Work Groups of the User and checks whether the User belongs to Admins Group and returns the result. If the result value is Admins then the Products Form is open in Read-Only Mode otherwise in Normal Mode. The Workgroups Array creation is necessary because a particular User can belong to one or more Workgroups, like Admins, Users (default), Supervisor, Manager, Editor or any other group in the Workgroup Information File(database.mdw), which he/she has been joined to. The Filter() Function compares the text "Admins" in the array elements and if found it is output into the GrpOut(0) element. We cannot use the Filter() Function in Form Module Sub-Rotuine, because it will clash with the Form Property name Filter. Coming back to the Open Arguments of Form and Reports we can pass the name of a Query as Filter Argument or a WHERE condition without the word WHERE. But, there is another parameter known as Open Argument (OpenArgs) through which you can pass a value to the Report or Form and read it back in the Class Module of Report or Form from the same variable OpenArgs and use it for whatever purpose you passed it. We try a simple example to learn the usage of this parameter. We need few objects from the C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb sample database.
A sample Form image is given below for reference. ![]()
The Products by Category Report will open with only Beverages items on the Report and the heading label modified to show the Product category Name. This time all the Products by Category will appear on the Report and the heading will remain without any change. We are testing the presence of some values in the OpenArgs Variable in the Report Open Event Procedure, if it is Null then terminate the Sub-Routine. Do the following to try the first two Programs given on the top of this page:
Form Bookmarks and Data Editing Run Slide-show when Form is idle Filter Function Output in ListBox-2 Filter Function Output in ListBox Dynamic List Box Contents |
You are subscribed to email updates from LEARN MS-ACCESS TIPS AND TRICKS To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.