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  

Form open code not always firing



 
 
Thread Tools Display Modes
  #1  
Old June 8th, 2004, 03:47 PM
Ron
external usenet poster
 
Posts: n/a
Default Form open code not always firing

My MDB runs a switchboard form on startup. The "on open"
for the switchboard has the code below. Basically, if
the person signing on is a supervisor, it closes the
regular switchboard and opens the supervisor's
switchboard.

The problem is that occasionally, the code doesn't fire
and the sysadmin will wind up with the regular
switchboard. If sysadmin immediately closes and re-opens
the mdb it usually opens correctly.

But how can I get it to consistently open correctly? The
supervisor is going to get honked off if she has to open
it twice to get the correct switchboard.


Private Sub Form_Open(CANCEL As Integer)
If (CurrentUser() = "Sysadmin" Or CurrentUser()
= "rturner") Then
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_SupervisorSwitchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.Maximize
End If
End Sub
  #2  
Old June 8th, 2004, 06:24 PM
Gerald Stanley
external usenet poster
 
Posts: n/a
Default Form open code not always firing

I have my doubts about using DoCmd.Close within the Open
eventhandler. Try replacing it with 'Cancel = True' and
see if that improves the situation.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
My MDB runs a switchboard form on startup. The "on open"
for the switchboard has the code below. Basically, if
the person signing on is a supervisor, it closes the
regular switchboard and opens the supervisor's
switchboard.

The problem is that occasionally, the code doesn't fire
and the sysadmin will wind up with the regular
switchboard. If sysadmin immediately closes and re-opens
the mdb it usually opens correctly.

But how can I get it to consistently open correctly? The
supervisor is going to get honked off if she has to open
it twice to get the correct switchboard.


Private Sub Form_Open(CANCEL As Integer)
If (CurrentUser() = "Sysadmin" Or CurrentUser()
= "rturner") Then
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_SupervisorSwitchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.Maximize
End If
End Sub
.

  #3  
Old June 9th, 2004, 04:51 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default Form open code not always firing

In addition to what Gerald advised, I would close / cacel
the StartUp Form *after* the opening of the
Form "frm_SupervisorSwitchboard". Something like:

****Untested****
Private Sub Form_Open(CANCEL As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

If (CurrentUser() = "Sysadmin") Or _
(CurrentUser() = "rturner") Then
stDocName = "frm_SupervisorSwitchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoEvents
Cancel = True
Else
DoCmd.Maximize
End If
End Sub
****

HTH
Van T. Dinh
MVP (Access)



-----Original Message-----
I have my doubts about using DoCmd.Close within the Open
eventhandler. Try replacing it with 'Cancel = True' and
see if that improves the situation.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
My MDB runs a switchboard form on startup. The "on

open"
for the switchboard has the code below. Basically, if
the person signing on is a supervisor, it closes the
regular switchboard and opens the supervisor's
switchboard.

The problem is that occasionally, the code doesn't fire
and the sysadmin will wind up with the regular
switchboard. If sysadmin immediately closes and re-

opens
the mdb it usually opens correctly.

But how can I get it to consistently open correctly?

The
supervisor is going to get honked off if she has to open
it twice to get the correct switchboard.


Private Sub Form_Open(CANCEL As Integer)
If (CurrentUser() = "Sysadmin" Or CurrentUser()
= "rturner") Then
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_SupervisorSwitchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.Maximize
End If
End Sub
.

.

 




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 06:45 PM.


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