If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Common form.open Routine
I want to set up security with a common routine run every time any form is
open. What's the best way to have a common routine for the on open event of every form? -- Jim |
#2
|
|||
|
|||
Common form.open Routine
Create a common function, and set the OnOpen event to
=FunctionName() (Make sure you include the equals sign and parentheses) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JimS" wrote in message ... I want to set up security with a common routine run every time any form is open. What's the best way to have a common routine for the on open event of every form? -- Jim |
#3
|
|||
|
|||
Common form.open Routine
Doug, if you don't mind a follow-up... how can I find all forms with no "on
open" event? Is it a property of the form object? Is it available from allforms, or do I need to open the form in design mode and check the property? I was planning to write a little routine (so I can practice writing routines....) to rifle through the allforms collection, and change the "on open" reference as you suggest.... Thanks again! -- Jim "Douglas J. Steele" wrote: Create a common function, and set the OnOpen event to =FunctionName() (Make sure you include the equals sign and parentheses) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JimS" wrote in message ... I want to set up security with a common routine run every time any form is open. What's the best way to have a common routine for the on open event of every form? -- Jim |
#4
|
|||
|
|||
Common form.open Routine
Sorry, Doug, I tried it (on the biggest, slowest-to-open form I have ever
written, of course...), and I became stumped. Here's the routine I wrote... Public Sub CheckAuthority(Cancel As Integer) If fnAuthorize(Me.Name) = False Then Cancel = True End If End Sub .... and the OnOpen event property says: =CheckAuthority() .... Now, it's not a function. If it should be a function, what does it return? Is it irrelevant? I'll try again, making it a function and returning a boolean. -- Jim "Douglas J. Steele" wrote: Create a common function, and set the OnOpen event to =FunctionName() (Make sure you include the equals sign and parentheses) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JimS" wrote in message ... I want to set up security with a common routine run every time any form is open. What's the best way to have a common routine for the on open event of every form? -- Jim |
#5
|
|||
|
|||
Common form.open Routine
Actually, you won't be able to use any value returned by the function. I
forgot that your intent is to prevent the form from opening. You're going to have to put Private Sub Form_Open(Cancel As Integer) Cancel = (fnAuthorize(Me.Name) = False) End Sub for all your forms. Sorry about that. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JimS" wrote in message news Sorry, Doug, I tried it (on the biggest, slowest-to-open form I have ever written, of course...), and I became stumped. Here's the routine I wrote... Public Sub CheckAuthority(Cancel As Integer) If fnAuthorize(Me.Name) = False Then Cancel = True End If End Sub ... and the OnOpen event property says: =CheckAuthority() ... Now, it's not a function. If it should be a function, what does it return? Is it irrelevant? I'll try again, making it a function and returning a boolean. -- Jim "Douglas J. Steele" wrote: Create a common function, and set the OnOpen event to =FunctionName() (Make sure you include the equals sign and parentheses) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JimS" wrote in message ... I want to set up security with a common routine run every time any form is open. What's the best way to have a common routine for the on open event of every form? -- Jim |
#6
|
|||
|
|||
Common form.open Routine
You need to open the form in design mode and check the property.
Given what I said in the other thread (that you can't use a function after all), you'll have to set the property to [Event Procedure], and add the sub to the form's module (take a look at the AddFromString method of the Module object) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JimS" wrote in message news Doug, if you don't mind a follow-up... how can I find all forms with no "on open" event? Is it a property of the form object? Is it available from allforms, or do I need to open the form in design mode and check the property? I was planning to write a little routine (so I can practice writing routines....) to rifle through the allforms collection, and change the "on open" reference as you suggest.... Thanks again! -- Jim "Douglas J. Steele" wrote: Create a common function, and set the OnOpen event to =FunctionName() (Make sure you include the equals sign and parentheses) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JimS" wrote in message ... I want to set up security with a common routine run every time any form is open. What's the best way to have a common routine for the on open event of every form? -- Jim |
Thread Tools | |
Display Modes | |
|
|