Cscott0685
New Member
- Joined
- Jan 4, 2018
- Messages
- 2
Long code short, I've created an ERP system for tracking shelf life for materials. The open sequence is as follows:
There is a textbox for user initials entry, and a "Login" button. Login Button checks for user existence, if exists, then...
.......
All in-between functions perform as expected, no issues when working with the forms.
The Close sequence, initiated by clicking the "Exit" command button, is as follows:
The "Application.Wait" was my attempt to allow Excel time to "catch up", hoping it would eliminate the issue.
This entire sequence (opening and closing) functions exactly as expected the first time I run through it.
After I click the "Exit" button, and allow the program to close, I start the sequence again from scratch (reopen the file).
The second time I open the file, it makes it to the Login form opening, I enter my initials, and click "Login", and that's where it crashes.
This makes absolutely no sense to me. If it functions as expected the first time through, I don't understand why it would crash the next time around.
Anyone have any insight as to what might be causing this? I've looked into "resetting" everything before (or after) opening (or closing), and couldn't find much information.
My goal is to:
Open the workbook
Load the Login UserForm
On correct login, load the Main UserForm
Make the Excel workbook minimized
'(do lots of stuff in between)
On "Exit" Click:
Hide the critical sheets in the workbook
Save the workbook
Exit Excel (not just unload the userform)
Thanks in advance!
On Workbook Object
Code:
[SIZE=2][SIZE=2][FONT=arial][COLOR=#000000][LEFT][COLOR=#222222][FONT=arial]Private Sub Workbook_Open() [/FONT][/COLOR]
[SIZE=2][COLOR=#222222][FONT=arial][COLOR=#000000] Sheets("Lists").Visible = True[/COLOR][/FONT][/COLOR][/SIZE]
[/LEFT]
Sheets("Materials").Visible = True[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=arial][COLOR=#000000] Sheets("CurrentMaterial").Visible = True[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=arial][COLOR=#000000] Sheets("Calendar").Visible = True[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=arial][COLOR=#000000] Sheets("Passwords").Visible = True[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=arial][COLOR=#000000] Sheets("LogSheet").Visible = True[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=arial][COLOR=#000000] Application.Wait (Now +TimeValue("0:00:05"))[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=arial][COLOR=#000000] UserForm_Login.Show[/COLOR][/FONT][/SIZE]
[/SIZE][FONT=arial][SIZE=2]End Sub
[/SIZE][/FONT]
On UserForm_Login Form
Code:
Private Sub UserForm_Initialize()
Application.DisplayAlerts = False
UserForm_Login.StartUpPosition = 2
End Sub
There is a textbox for user initials entry, and a "Login" button. Login Button checks for user existence, if exists, then...
.......
Code:
Else
Me.OperItlsTextBox.Value = Null
A[COLOR=#222222]pplication.WindowState = xlMinimized
[/COLOR][LEFT][COLOR=#222222] UserForm_Main.Show
[/COLOR][/LEFT]
End If
Unload UserForm_Login
End Sub
On UserForm_Main Form
Code:
[LEFT][COLOR=#222222][FONT=arial]Sub UserForm_Initialize[/FONT][/COLOR][/LEFT]
[FONT=arial][SIZE=2][COLOR=#000000]Application.DisplayAlerts = False[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] With UserForm_Main[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] .Width =Application.Width[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] .Height =Application.Height[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] .Top = 0[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] .Left = -8[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] .StartUpPosition = 3[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000]End With[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][LEFT][COLOR=#222222][LEFT][COLOR=#222222][FONT=arial] 'Set up TreeView, Show/Hide Command Buttons, Run "Material Remove" Macro, etc.[/FONT][/COLOR][/LEFT]
End Sub
[/COLOR][/LEFT]
[/SIZE][/FONT]
All in-between functions perform as expected, no issues when working with the forms.
The Close sequence, initiated by clicking the "Exit" command button, is as follows:
Code:
[FONT=arial][SIZE=2][COLOR=#000000]
Sub ExitCommandButton()[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] If MsgBox("ExitProgram?", vbYesNo) = vbYes Then[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] UserForm_Main.Hide[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Sheets("Lists").Visible = False[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Sheets("Materials").Visible = False[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Sheets("CurrentMaterial").Visible= False[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Sheets("Calendar").Visible = False[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Sheets("Passwords").Visible = False[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Sheets("LogSheet").Visible = False[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Application.Wait (Now+ TimeValue("0:00:05"))[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] ActiveWorkbook.Save[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Application.Wait (Now+ TimeValue("0:00:05"))[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] Application.Quit[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000] End If[/COLOR][/SIZE][/FONT]
[FONT=arial][SIZE=2][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]
The "Application.Wait" was my attempt to allow Excel time to "catch up", hoping it would eliminate the issue.
This entire sequence (opening and closing) functions exactly as expected the first time I run through it.
After I click the "Exit" button, and allow the program to close, I start the sequence again from scratch (reopen the file).
The second time I open the file, it makes it to the Login form opening, I enter my initials, and click "Login", and that's where it crashes.
This makes absolutely no sense to me. If it functions as expected the first time through, I don't understand why it would crash the next time around.
Anyone have any insight as to what might be causing this? I've looked into "resetting" everything before (or after) opening (or closing), and couldn't find much information.
My goal is to:
Open the workbook
Load the Login UserForm
On correct login, load the Main UserForm
Make the Excel workbook minimized
'(do lots of stuff in between)
On "Exit" Click:
Hide the critical sheets in the workbook
Save the workbook
Exit Excel (not just unload the userform)
Thanks in advance!