Goto Command in Code

  • Thread starter Thread starter JimPNicholls
  • Start date Start date
J

JimPNicholls

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??
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top