ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Goto Command in Code (https://www.excelbanter.com/excel-programming/308607-goto-command-code.html)

JimPNicholls

Goto Command in Code
 
Excel 2k


I have two forms (Form1 & form2). Form 1 has code within
it that checks various cells in a worksheet. I have some
validation within where if the cell value < "" then Form2
pops up and asks whether the user is sure that they want
to continue and update the worksheet. If they click on
yes, the worksheet appears. If they choose "No", I want
the code to resume in Form1. Although I knows it not good
practice to use the Goto command, its the only solution I
could think off but I can't get it to work. Any help
avaliable??

Robin Hammond[_2_]

Goto Command in Code
 
Jim,

you could try this...

Have the update code in Form1, and the main control logic there, so that it
is always the one that is really in control.

on Form2, have an invisible label, called lblCancel.

Code structure then looks like this

Sub Main
Form1.Show
End Sub

In Form1 code
cmdDoSomething_Click
Me.Hide
Form2.Show
If Form2.lblCancel.Caption = "TRUE" then
Unload Form2
Else
'do something
Unload Form2
End If
End Sub

In Form2 code
cmdCancel_Click
lblCancel.Caption = "TRUE"
me.hide
End Sub

cmdOK_Click
me.hide
End Sub

Robin Hammond
www.enhanceddatasystems.com

"JimPNicholls" wrote in message
...
Excel 2k


I have two forms (Form1 & form2). Form 1 has code within
it that checks various cells in a worksheet. I have some
validation within where if the cell value < "" then Form2
pops up and asks whether the user is sure that they want
to continue and update the worksheet. If they click on
yes, the worksheet appears. If they choose "No", I want
the code to resume in Form1. Although I knows it not good
practice to use the Goto command, its the only solution I
could think off but I can't get it to work. Any help
avaliable??




Frank Stone

Goto Command in Code
 
put code behind form2 to open form1 and close form2
-----Original Message-----
Excel 2k


I have two forms (Form1 & form2). Form 1 has code within
it that checks various cells in a worksheet. I have some
validation within where if the cell value < "" then

Form2
pops up and asks whether the user is sure that they want
to continue and update the worksheet. If they click on
yes, the worksheet appears. If they choose "No", I want
the code to resume in Form1. Although I knows it not good
practice to use the Goto command, its the only solution I
could think off but I can't get it to work. Any help
avaliable??
.



All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com