View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Alan Alan is offline
external usenet poster
 
Posts: 188
Default 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