Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Flow of control in VBA Question - Userform Interaction
Hi All,
I have a situation that simplifies to the code below. My question is: When the userform unloads due to the admin button being clicked, and the correct password being entered, does control go back to the Workbook_Open code sub, and run the code after my 'Remainder comment? I seem to be getting inconsistent results from this is different situations, but obvoiusly that is me not understanding how it works. Hope that makes sense? Alan. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Private Sub Workbook_Open: ' Does stuff frmMainMenu.Show ' Remainder End Sub In userform: Private Sub cmdAdministration_Click() ' Allows the admin user to exit from code control and access the underlying spreadsheet InputPassword = InputBox("This will allow you to make manual adjustments directly to the database, add or change locations, types, sales reps etc." & Chr(13) & Chr(13) & _ "You will be outside the control of the system, and substantial damage could be caused to the database." & Chr(13) & Chr(13) & _ "If you are sure you want to continue, please enter the admin password, else click cancel.", "Administration Password Required") If InputPassword = Password Then Application.CalculateFull Application.Calculation = xlCalculationAutomatic Unload Me End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Flow of control in VBA Question - Userform Interaction
Alan,
That is how it should work. If you put breaks in the code, you should see the course of events. -- HTH RP (remove nothere from the email address if mailing direct) "Alan" wrote in message ... Hi All, I have a situation that simplifies to the code below. My question is: When the userform unloads due to the admin button being clicked, and the correct password being entered, does control go back to the Workbook_Open code sub, and run the code after my 'Remainder comment? I seem to be getting inconsistent results from this is different situations, but obvoiusly that is me not understanding how it works. Hope that makes sense? Alan. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Private Sub Workbook_Open: ' Does stuff frmMainMenu.Show ' Remainder End Sub In userform: Private Sub cmdAdministration_Click() ' Allows the admin user to exit from code control and access the underlying spreadsheet InputPassword = InputBox("This will allow you to make manual adjustments directly to the database, add or change locations, types, sales reps etc." & Chr(13) & Chr(13) & _ "You will be outside the control of the system, and substantial damage could be caused to the database." & Chr(13) & Chr(13) & _ "If you are sure you want to continue, please enter the admin password, else click cancel.", "Administration Password Required") If InputPassword = Password Then Application.CalculateFull Application.Calculation = xlCalculationAutomatic Unload Me End If End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Flow of control in VBA Question - Userform Interaction
Alan wrote:
I seem to be getting inconsistent results from this is different situations, but obvoiusly that is me not understanding how it works. You could try using OnTime in the Workbook_Open to run a Sub Main containing you 'Does stuff' etc code. I don't know if this would yield more consistent results but at least you would have peace of mind that the workbook is finishing opening before your code takes effect. Jamie. -- |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Flow of control in VBA Question - Userform Interaction
That's a very good point Jamie. I have had a few instances where code does
not seem to get executed, and adding Ontime to fir a routine that executed that routine solved the problem. Had it with menubars, and with forms. -- HTH RP (remove nothere from the email address if mailing direct) "onedaywhen" wrote in message oups.com... Alan wrote: I seem to be getting inconsistent results from this is different situations, but obvoiusly that is me not understanding how it works. You could try using OnTime in the Workbook_Open to run a Sub Main containing you 'Does stuff' etc code. I don't know if this would yield more consistent results but at least you would have peace of mind that the workbook is finishing opening before your code takes effect. Jamie. -- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Where are the flow shape and flow connector tabs in Vista? | Charts and Charting in Excel | |||
How to create a macro to control data flow | Excel Discussion (Misc queries) | |||
How do I label flow connectors in and excel flow chart? | Excel Discussion (Misc queries) | |||
flow chart question | Charts and Charting in Excel | |||
UserForm Interaction | Excel Programming |