|
Creating Using Form Custom Property Posted: 29 Nov 2009 10:11 AM PST Parameter Controls are provided to the Users for entering data Filter criteria values for preparing MS-Access Reports. A reference to the parameter control fields can be set in the criteria row of the Report Source Query directly to filter the data. A sample image of such a Parameter Control is given below. The above Report Parameter Control gives flexibility to the User to set a Date Range in the fields provided on the screen before opening one of two Report Options provided. When the User Clicks on the Preview Command Button the Report will be opened with data filtered using the Parameter Control Date Range values set as Criteria on the Source Query. To record the Date Range values (Date From and Date To) a small Table with two fields is created with a single record and used as Record Source to the above Form. The idea behind the use of a Table is to preserve the last used Report Parameter Values in the Table. Next time when we open the Form we will know for which period we have prepared the Report earlier. The parameter table can also be used in the Query to link with the Data Table or use its value as criteria in the criteria Row of the Report Source Query. The following two Form Property Values must be set as shown below to prevent adding new Records to the Table and not to delete the existing one: Allow Additions = No Allow Deletion = No This method works fine when the Database is a Single User one. But, when the database is shared on a Network there is a problem to this method. Different Users may open the same Parameter Screen at the same time to prepare their version of the same Report. They will attempt to change the parameter values at the same time. This action will end up with a record edit lock error or the values set can cross over and the Report printed can go wrong too. Even though the Users can open different instances of the same Form on their machines the Record Source Table is same. We are focusing on this particular aspect to see how we can safely provide the above Parameter Control to the Users to work safely without clashing each other. Perhaps, you have the right solution to this problem by now. Yes, do not use the Parameter Table to store the Report criteria values; instead create two Unbound Text Boxes on the Form, as you have rightly guessed. This will ensure that all Users will work independently on their own instances of the Report Parameter Form and no chance of clashing with each other's values. There is only a minor draw back in this method; you cannot store the last used Report Parameter Value anywhere so that it will be displayed next time when you open the Form. At least one set of value is required when you open the Form next time. If these controls remain empty and if you run the Preview option without setting the parameter values then the Report will be empty and will end up showing #Error in all controls with expressions created for Summary Values. I have already published an Article on this topic earlier as how to open the Report without this Error condition when the Report Source Query or Table is empty. Click here to find out. We can save the values, from the Unbound Text Box controls, on the Parameter Form itself in Custom Properties, which we can create on the Form. Managing data in Custom Properties can be done only through VBA and these Property Names and their Values are not visible on the Property Sheets that we normally work with. Click here to find out more details on Custom Properties and a method that we have used earlier to open the Form with last edited record as current on the Form. We have to go through the following procedure to manage the User data on the Form itself without the use of a Table as Record Source:
This is required only once. A small VBA Program is required in the Standard Module to create the Custom Properties on the Form. In the Program the Parameter Form Name is required for reference. Not necessary to keep the Form in Design View to create the Custom Properties.
How do you know whether these Properties are created or not? Try running the Program again and this will tell you that these Property names already exist on the Form. If you want to Delete these Properties from the Form then Run the following Code:
Close the Form and open it again in Normal View. The date values you have entered earlier will appear in both Unbound Text Boxes. Even after implementing this method I am not fully happy with it. Because, it will preserve only one of the Values, set by different Users working with the Form at the same time. What I would like to see as a User is that the last value that I set on the Report Parameter Field is appearing on the Form again when I open the Form next time, not the value set by someone else. Is it possible? Yes, it is possible. We will see how to do this next week. Office Assistant and MsgBox Menus Color and Picture in MsgBox Microsoft Excel Power in Access Un-secured Database and Users-Log MS-Access Report and Page Total |
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.