Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5936123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:21:15+00:00 2026-05-22T15:21:15+00:00

and thanks in advance for helping. I am creating a log in screen for

  • 0

and thanks in advance for helping. I am creating a log in screen for some workbooks Upon thisworkbook being open I have “userform1.show” and in the userform i have hardcoded a username and password. when the userform1 pops up asking for username and password I am able to click the X and it just closes the form and the user can still use the workbook. How do I have that X close the entire workbook. I don’t know what that X is called in VB. I have tried “application.enablecancelkey” with all 3 options but none work.

A) is that the right way to go about it?
B) if it is where do I put that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:21:16+00:00Added an answer on May 22, 2026 at 3:21 pm

    You could write

    Private Sub UserForm_QueryClose(cancel As Integer, CloseMode As Integer)
        If CloseMode = 0 Then
            ThisWorkbook.Close
        End If
    End If
    

    Alternatively you could also prevent the Login Form being closed by the “X“

    Private Sub UserForm_QueryClose(cancel As Integer, CloseMode As Integer)
        If CloseMode = 0 Then
            cancel = 1
            MsgBox "Please use cancel if you want to leave the Login Box.", _
                vbOKOnly + vbInformation, "Please confirm ..."
        End If
    End Sub
    

    That’s how we do it with our logins…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks in advance for helping me out (for those who have time and are
Hi Thanks in advance for helping. I have the following table: create table temp_vol
Thanks in advance for helping, I have a list of one million names and
Sorry if this is too simple, but thanks in advance for helping. This is
Thanks in advance for your help. I have a need within an application to
Thanks in advance for your assistance. I have the following exported part: [Export (typeof(INewComponent))]
First of all I want to say thanks in advance for helping me. I
I am considering helping an open-source gaming project with creating their setup file. The
Thanks in advance to anyone who can think of a more efficient or a
thanks in advance for looking at this. Essentially, I'm calling didInsertElement() and binding an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.