PDA

View Full Version : Solved: Stop Form Closing "X"



khalid79m
01-19-2011, 05:53 AM
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If Cancel <> 1 Then
Cancel = -1
End If
End Sub

I have the above code that disables the X in the top right, but how can I then get a macro to unload the form.

This form is a feedback form , once this form is loaded it is compulsary for it to be filled in! hence the removal of the X in top right.

see code below for the commaned, the unload me re laucnches the above code and stops the unload


Private Sub CommandButton1_Click()
MsgBox "Transfer data to shared location , 1 call = 1 txt file"
If SCCS_Feedback.FDB_Step_01 <> "" Then SCCS_Feedback.FDB_Step_01_Chk = True
If SCCS_Feedback.FDB_Step_02 <> "" Then SCCS_Feedback.FDB_Step_02_Chk = True
If SCCS_Feedback.FDB_Step_03 <> "" Then SCCS_Feedback.FDB_Step_03_Chk = True
If SCCS_Feedback.FDB_Step_04 <> "" Then SCCS_Feedback.FDB_Step_04_Chk = True
If SCCS_Feedback.FDB_Step_01_Chk = True And SCCS_Feedback.FDB_Step_02_Chk = True And SCCS_Feedback.FDB_Step_03_Chk = True And SCCS_Feedback.FDB_Step_04_Chk = True Then
MsgBox "Pass"

Dim XXX

XXX = ThisWorkbook.Sheets("FB").Range("AA2").Value & _
SCCS_Feedback.FDB_Step_01.Value & "|" & _
SCCS_Feedback.FDB_Step_02.Value & "|" & _
SCCS_Feedback.FDB_Step_03.Value & "|" & _
SCCS_Feedback.FDB_Step_04.Value & "|"

MsgBox XXX

X_Site = ThisWorkbook.Sheets("FB").Range("A2").Value
If X_Site = "ZZ" Then X_Path = "Z" Else
If X_Site = "MM" Then X_Path = "M"

MsgBox X_Path

Unload Me
SCCS_Call_Selector.Show
Else
MsgBox "Blah Blah", vbExclamation

End If
End Sub

GTO
01-19-2011, 06:05 AM
If Not CloseMode = vbFormCode Then Cancel = True
You were checking against Cancel, which will initially be 0. You want to check the CloseMode instead.

Mark

khalid79m
01-24-2011, 08:02 AM
Perfectooooo