Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2005, 08:42 AM
Authorized User
 
Join Date: Sep 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default close all userforms and pass control back to sub

Hi -

I am creating a macro that accepts users input via user forms and then process the data to create an excel spreadsheet data.

The way I designed the macro is to have a sub route in a standard module that calls(shows) a main userform which then determines which other userform to show, based on the user's input to the main userform. In switching between main userform and other userform, I use "hidden" to hide userform. On the main userform, I have created a "finish" command control, so that I can close all user forms and pass the control back to the sub routin in the stand module and runs process the input.

However, I am having problem with accomplish such. I have the following code in my main userform. How do then close the main userform and pass the flow back to the main subroute where I have started? I tried to use "unload " in the code. but it did not work either.

Private Sub CmdFinish_Click() ' in the main user form

        If va_fmChemPharm_Hide = True Then
            Unload fmChemPharm
        End If
        If va_fmPreClinical_Hide = True Then
            Unload fmPreClinical
        End If
        If va_fmFunctionMenu_Hide = True Then
            Unload fmFunctionMenu
        End If

End Sub

Any help, greatly appreciate.

Kathy
 
Old February 1st, 2005, 04:14 AM
Authorized User
 
Join Date: Jan 2005
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Good Question!

I have followed your problem and created a dummy application in which one form opens the other, the other opens the other and so on.

An I have reached to the mark where you have got stuck up, and so do I.

I am applying thoughts on it, in the mean time just accept my appreciation, it's good thing to workout.

Give me a day or so for the work arround.

Thanks

Amjad Mahmood

 
Old February 1st, 2005, 06:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

maybe I'm missing a trick here but have you not tried:

Code:
Private Sub CmdFinish_Click()      ' in the main user form

        If va_fmChemPharm_Hide = True Then
            Unload fmChemPharm
        End If
        If va_fmPreClinical_Hide = True Then
            Unload fmPreClinical
        End If
        If va_fmFunctionMenu_Hide = True Then
            Unload fmFunctionMenu
        End If

        ' Close main UserForm
        Me.Hide
        Unload Me

End Sub
 
Old February 2nd, 2005, 12:51 AM
Authorized User
 
Join Date: Jan 2005
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes that's it!

It worked with my file, by just replacement of my CmdFinish_Click() with yours

Thanks you.

Can you can express "in nut shell" what we have learnt? I mean "the form unload rule"







Similar Threads
Thread Thread Starter Forum Replies Last Post
Open modal window and pass back url to parent nambati Javascript 3 March 23rd, 2010 08:03 AM
ASP. Button Control not posting back innochig ASP.NET 1.0 and 1.1 Professional 16 January 15th, 2007 05:15 PM
Pass XSL variable back to asp.net page ayamas XSLT 8 September 14th, 2006 06:07 AM
Capture Control Identity Causing Autopost Back jmd ASP.NET 1.0 and 1.1 Basics 2 January 15th, 2005 11:01 AM
how to pass back the values to applet. kfarooq Servlets 1 July 23rd, 2003 12:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.