Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Every post I've found for this problem seems to have been resolved with
Application.ScreenUpdating = True. Not in this case. With 2 UserForms, Form 1 remains visible behind Form 2, even though Form 1 was unloaded before Form 2 was loaded & shown. The main code module (all variables are Public): Sub ACRE_MthCtrb() Application.ScreenUpdating = True ThisWorkbook.Activate FilPth = ThisWorkbook.Path & "\" << The 1st UserForm loads, executes & unloads in function VldLogin() . This form & function are in a separate, hidden workbook, with a reference set in the current workbook. LoginVld = VldLogin() If Not LoginVld = True Then ActiveWindow.Close _ SaveChanges:=False End If << Here, the 2nd UserForm, ProgBar, appears. The 1st form already unloaded. Application.ScreenUpdating = False ProgBar.LblProgBar.Width = 0 ProgBar.Show << Remainder of processing is in Sub Prc(), called from UserForm ProgBar Workbooks("ACRE Monthly Contributions.xls").Activate Application.ScreenUpdating = True ActiveWindow.Close _ SaveChanges:=False End Sub Sub Prc() .. .. .. End of module << The 1st UserForm, QryLogin, loads in this module, Login: Public Function VldLogin() As Boolean Abt = vbNo Load QryLogin QryLogin.Show If Abt = vbYes Then VldLogin = False Else VldLogin = True End If End Function << Userform QryLogin contains the following code: Private Sub OK_Click() Dim LoginAut As Boolean If Len(Trim(Me.UsrID)) = 0 Then MsgBox ("You Must Enter A User Name") Me.UsrID.SetFocus ElseIf Len(Trim(Me.Psw)) = 0 Then MsgBox ("You Must Enter A Password") Me.Psw.SetFocus Else LoginAut = AutLogin(Me.UsrID, Me.Psw) If LoginAut = True Then Login.UsrID = Me.UsrID.Value Login.Psw = Me.Psw.Value << Here is the Unload for the 1st form Unload Me Else MsgBox ("Invalid Username or Password; Please Re-Enter") Me.UsrID.SetFocus End If End If End Sub Function AutLogin(ByVal UsrID As String, _ ByVal Psw As String) _ As Boolean Const ADS_SECURE_AUTHENTICATION = 1 Dim Aut As Object ' Authentication Dim Dmn As String ' Domain Dim G_C As Object ' Global Catalog Dim Root As Object ' RootDSE On Error Resume Next Set Root = GetObject("GC://rootDSE") Dmn = Root.Get("defaultNamingContext") Set G_C = GetObject("GC:") Set Aut = G_C.OpenDSObject("GC://" & Dmn, UsrID, Psw, ADS_SECURE_AUTHENTICATION) If Aut Is Nothing Then AutLogin = False Else AutLogin = True End If Set Aut = Nothing Set G_C = Nothing Set Root = Nothing End Function << The 2nd UserForm, ProgBar, conatains this code: Private Sub UserForm_Activate() Call Prc Unload Me End Sub Stepping thru the logic, it works fine; Form 1 disappears before Form 2 appears. Running full-bore, Form 1 remains visible behind Form 2 the entire time the program runs. Since screen updating is off at this time, the processing is not seen behind Form 1, which is correct. I have tried moving the 'ScreenUpdating = False' statement further on in the code but to no avail. Is there, perhaps, a UserForm property or some Excel setting that would cause this? -- Will |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unload a UserForm | Excel Programming | |||
unload userform | Excel Programming | |||
Unload a Userform created in VB6 | Excel Programming | |||
Using VB to password protect, but sheet remains visible | Excel Discussion (Misc queries) | |||
load/unload userform | Excel Programming |