View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mark Dullingham Mark Dullingham is offline
external usenet poster
 
Posts: 92
Default Conditional Unloading of a Userform (I've got in a right pickle)

The Story so far!

I have a userform with 3 Command buttons and 2 toggle buttons.

The 2 tog buts trigger an ontime event each in a standard mudule. this all
works fine.
1 command button hides the userform and the other one, which is a cancel
button is where I'm having a bit of a problem.

What I want to happen is when clicked, the state of the 2 tog but are
checked and if both are false, then unload the form. If either one or both
are true then a message box pops up with do you want to continue with vbYes
and vbNo buttons.
If the user says yes then a sub is run to change tog buttons to false then
the form unloads. If no is chosen then the msgbox diappears and the userform
is left open.

Hears what i have so far

Private Sub CommandButton1_Click()
On Error Resume Next
MkDir "C:\AutoSaves"
On Error GoTo 0
End Sub

Private Sub CommandButton2_Click() 'Caption is Hide
frmOptions.Hide
End Sub


Private Sub CommandButton3_Click() ' Caption is Cancel
If frmOptions.ToggleButton1.Value = True Then
ElseIf frmOptions.ToggleButton2.Value = True Then 'Can these to line be
combine to give
' a boolean and argument
Dim Msg, Style, Title, Response
Msg = "Do you want to Cancel Auto Save ?" 'This bit all works fine
Style = vbYesNo
Title = "Cancel Auto Save Options"

Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
CancelToggles ' Run sub

Else ' User chose No.
Hide ' Hides the userform
End If ' upto hear happens if either one or both the toggle buttons are true



Else
Unload Me 'I want the userform to unload if both togglr buttons are false
End If
End If
End Sub

Private Sub CancelToggles()
ToggleButton1.Value = False
ToggleButton2.Value = False
End Sub


Can normal ws funtions like AND and LOGICAL be call upon for something like
this?

Please help my brain is liquifying and draining out my ears!