Protecting Reports by using VBA Code


Protecting Reports by using VBA Code

The best ways to protect and secure individual report designs are to compile the database in MDE format (see the section "The MDE Database Format Revisited" in this chapter), to use the Hidden property (see Chapter 3), and to use workgroup security (Chapter 8 and the section "A Workgroup Security Refresher" earlier in this chapter). If you are not sure about the MDE format, consider using the following programming technique to stop people from opening the report in design view.

Just like with forms in the previous section, you can also open reports as class modules to protect them from being opened in design mode. The VBA code to do this is very similar to that demonstrated for a form class, and you can find the subroutine in the basOpenProtected module and the code that calls that subroutine in the form frmClassy . The code follows .

 Sub ProtectOrdersReport() ' Open the Orders report as a class object to protect it from ' being opened in design mode. ' If you include this code in a form module, the report below ' will be closed when the form that opens it closes. On Error GoTo ProtectOrdersReport_error Static clsRptOrders As Report_rptOrders Set clsRptOrders = New Report_rptOrders With clsRptOrders    .Caption = "Real World Orders Report That Cannot Be Designed"    .Visible = True End With ProtectOrdersReport_exit:    Exit Sub ProtectOrdersReport_error:    MsgBox "Error number " & Err.Number & " ... " & Err.Description    GoTo ProtectOrdersReport_exit End Sub 

That code provides just about all the additional security techniques that you can use for reports. Now we will review the protection that is available for macros.




Real World Microsoft Access Database Protection and Security
Real World Microsoft Access Database Protection and Security
ISBN: 1590591267
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net