Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where are the flow shape and flow connector tabs in Vista? brad Charts and Charting in Excel 1 March 29th 08 04:53 AM
How to create a macro to control data flow JW_4222 Excel Discussion (Misc queries) 1 March 28th 08 02:33 PM
How do I label flow connectors in and excel flow chart? Hannah Excel Discussion (Misc queries) 1 September 7th 06 07:55 PM
flow chart question sunrosejenn Charts and Charting in Excel 3 March 1st 06 09:53 PM
UserForm Interaction Bob Phillips[_5_] Excel Programming 0 September 22nd 03 08:12 PM


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"