ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable the redX in a form (https://www.excelbanter.com/excel-programming/413792-disable-redx-form.html)

Ewing25

Disable the redX in a form
 
Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If


Range("Cardholder_Number").AutoFilter
Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex

Coder1215

Disable the redX in a form
 
On Jul 9, 7:16*pm, Ewing25 wrote:
Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
* * *Message = "Please Enter Last 5 Digits of Your Card Number"
* * Title = "AMEX Number" *'<--Change
* * MyValue = InputBox(Message, Title)

*If MyValue = "" Then
* *Sheets("Expense Amex").Protect password:="welcome"
* Exit Sub

*End If

* * Range("Cardholder_Number").AutoFilter
* * Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
* * Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex


Hi Alex,

Try to include following code in your form:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
'message maybe
End If
End Sub

regards

Peter

PCLIVE

Disable the redX in a form
 
Alex,

My understanding is that you cannot disable the Close X on an InputBox.
However, using code you can disable one on a userform. I believe that is
what the other reply was trying to tell you, even though you aren't
currently using a UserForm.

Using this code in your UserForm will force a user to click a command button
to close the form. If the user clicks the X, a message will appear telling
them it is disabled.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = 0 Then
Cancel = True
MsgBox "The X is disabled, please use a button on the form.",
vbCritical
End If

End Sub



Regards,
Paul
--

"Ewing25" wrote in message
...
Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If


Range("Cardholder_Number").AutoFilter
Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex




Ewing25

Disable the redX in a form
 
I added it like this and it doesnt seem to work. Any suggestions?

Dim Message2, Title2, MyValue
Dim Cancel As Integer
Dim CloseMode As Integer
If CloseMode = vbFormControlMenu Then
Cancel = True



Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If
End If

"Coder1215" wrote:

On Jul 9, 7:16 pm, Ewing25 wrote:
Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If

Range("Cardholder_Number").AutoFilter
Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex


Hi Alex,

Try to include following code in your form:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
'message maybe
End If
End Sub

regards

Peter


Ewing25

Disable the redX in a form
 
So to achieve what im trying to do i have to create a userform and put the
code behind that?

"PCLIVE" wrote:

Alex,

My understanding is that you cannot disable the Close X on an InputBox.
However, using code you can disable one on a userform. I believe that is
what the other reply was trying to tell you, even though you aren't
currently using a UserForm.

Using this code in your UserForm will force a user to click a command button
to close the form. If the user clicks the X, a message will appear telling
them it is disabled.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = 0 Then
Cancel = True
MsgBox "The X is disabled, please use a button on the form.",
vbCritical
End If

End Sub



Regards,
Paul
--

"Ewing25" wrote in message
...
Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If


Range("Cardholder_Number").AutoFilter
Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex





Gary Brown[_4_]

Disable the redX in a form
 
Do While MyValue = ""
MyValue = InputBox(Message, Title)
Loop

....will keep the inputbox showing until something is entered.
--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown


"Ewing25" wrote:

Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If


Range("Cardholder_Number").AutoFilter
Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex


Ewing25

Disable the redX in a form
 
That works great! thanks!

"Gary Brown" wrote:

Do While MyValue = ""
MyValue = InputBox(Message, Title)
Loop

...will keep the inputbox showing until something is entered.
--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown


"Ewing25" wrote:

Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If


Range("Cardholder_Number").AutoFilter
Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex


Jim Thomlinson

Disable the redX in a form
 
While I am not saying don't do what you are planning on doing, I have found
that users don't like mandatory fields that they can not get out of. IMO you
are better off to catch where they have exited the input without entering
anything and letting them know the consequences of leaving that field blank.
Then allow them to try again ro whatever is needed...
--
HTH...

Jim Thomlinson


"Ewing25" wrote:

That works great! thanks!

"Gary Brown" wrote:

Do While MyValue = ""
MyValue = InputBox(Message, Title)
Loop

...will keep the inputbox showing until something is entered.
--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown


"Ewing25" wrote:

Okay so i have a inputbox that pops up from this code.

Dim Message2, Title2, MyValue
Message = "Please Enter Last 5 Digits of Your Card Number"
Title = "AMEX Number" '<--Change
MyValue = InputBox(Message, Title)

If MyValue = "" Then
Sheets("Expense Amex").Protect password:="welcome"
Exit Sub

End If


Range("Cardholder_Number").AutoFilter
Range("Cardholder_Number").AutoFilter Field:=1, Criteria1:=MyValue,
visibleDropDown:=False
Sheets("Expense Amex").Protect password:="welcome"
On Error Resume Next

What i want to do is make it so they cant press the red X in the top right
of the form. how do i do this?

Thanks,
Alex


Harald Staff[_2_]

Disable the redX in a form
 
Very true, Jim. Users will Ctrl Alt Delete their way out of the painful
experience and refuse to touch it ever after.

Best wishes Harald

"Jim Thomlinson" wrote in message
...
While I am not saying don't do what you are planning on doing, I have
found
that users don't like mandatory fields that they can not get out of. IMO
you
are better off to catch where they have exited the input without entering
anything and letting them know the consequences of leaving that field
blank.
Then allow them to try again ro whatever is needed...
--
HTH...

Jim Thomlinson


"Ewing25" wrote:

That works great! thanks!

"Gary Brown" wrote:

Do While MyValue = ""
MyValue = InputBox(Message, Title)
Loop

...will keep the inputbox showing until something is entered.




All times are GMT +1. The time now is 09:59 AM.

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