A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Common form.open Routine



 
 
Thread Tools Display Modes
  #1  
Old May 8th, 2008, 09:00 PM posted to microsoft.public.access.forms
JimS
external usenet poster
 
Posts: 252
Default 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  
Old May 8th, 2008, 10:15 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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  
Old May 8th, 2008, 10:29 PM posted to microsoft.public.access.forms
JimS
external usenet poster
 
Posts: 252
Default 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  
Old May 8th, 2008, 10:53 PM posted to microsoft.public.access.forms
JimS
external usenet poster
 
Posts: 252
Default 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  
Old May 9th, 2008, 12:14 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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  
Old May 9th, 2008, 12:17 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:11 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.