What would be a standard way to return which button someone has pressed. I.E:
I have an OK/Cancel button and if the user presses OK the page is printed. How do i get there response so i can then do
(Code)
If response = OK Then
Sheet1.PrintOut
End If
I assume the button is on a form you activated with its "show" method on a previous line of code? A straightforward way of passing the response back would be with a public variable:
public PrintIt as boolean
...
sub OKButton_click()
...
PrintIt=true
unload me
end sub()
sub userform_activate()
...
PrintIt=false
end sub()
If you don't like public variables, you can instead use the "tag" property of your OKButton:
sub OKButton_click()
...
OKButton.tag="clicked"
me.hide
end sub()
...
MyForm.Show
if MyForm.OKButton.tag="clicked" then
...
end if
Myform.Unload
Note you can't unload the form in this case until you've checked the button status.
I'm sure there are many other solutions.
Rob
just set a variable to get the msgbox return value:
sub tranpkp()
d = MsgBox("WHICH?", vbYesNoCancel, "TRANPKP"
If d = vbYes Then
MsgBox ("YES"
End If
end sub
[/green]
Tranpkp ************************************ - Let me know if this helped/worked! Please remember to give helpful posts the stars they deserve!
This facilitates others navigating through the threads / posts!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.