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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|