Results 1 to 4 of 4
  1. #1
    netguy is offline Novice
    Windows 8 Access 2007
    Join Date
    Sep 2014
    Posts
    16

    Close access


    Hey folks I have a form 'modal' that loads when access is first opened and allows a user to login using a simple form. I want to be able to close the application if the user clicks on the x in the upper right corner of the form. I have already applied script to close application if the user presses the close/cancel button however is there a way to apply the same script to the native close x icon?

    Private Sub Command0_Click()
    DoCmd.Quit
    End Sub

  2. #2
    netguy is offline Novice
    Windows 8 Access 2007
    Join Date
    Sep 2014
    Posts
    16
    I thought OnClose event would work however even if the user uses the correct username and password the form is suppose to close and redirect to another form. However onClose closes closes the application. Its the dreadful close loop. I just want to restrict a user from going around the SIMPLE security I've created by closing the form out by clicking on the "x"

  3. #3
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Put the same code in form's close event.

  4. #4
    netguy is offline Novice
    Windows 8 Access 2007
    Join Date
    Sep 2014
    Posts
    16
    amrut - I tried that. Here's the code I use for simple security:

    Not sure what code to use if they press the "x" and where to put it

    This code is on a close button ive placed on the form:
    Private Sub Command0_Click()
    DoCmd.Quit
    End Sub


    This code is ran when selecting the login button. As you can see because I close the form then the DoCMD Quit would run even if the user successfully logs in


    Private Sub Command1_Click()
    If IsNull(Me.txtLoginID) Then
    MsgBox "Please enter LoginID!", vbInformation, "LoginID Required"
    Me.txtLoginID.SetFocus
    ElseIf IsNull(Me.txtPassword) Then
    MsgBox "Please enter Password!", vbInformation, "Password Required"
    Me.txtPassword.SetFocus
    Else
    'process the job
    If (IsNull(DLookup("UserLogin", "tbl_users", "UserLogin ='" & Me.txtLoginID.Value & "'"))) Or _
    (IsNull(DLookup("Password", "tbl_users", "Password ='" & Me.txtPassword.Value & "'"))) Then
    MsgBox "Incorrect Login or Password"

    'ElseIf Me.txtPassword.Value = "password" Then
    ' MsgBox "Please change your password"
    ' DoCmd.Close


    Else
    DoCmd.Close
    DoCmd.OpenForm "MAIN"
    End If

    End If
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can Access be programmed to close itself?
    By dunc723 in forum Programming
    Replies: 2
    Last Post: 05-27-2014, 12:11 PM
  2. Replies: 4
    Last Post: 01-31-2014, 11:47 AM
  3. Access does not close Excel App
    By John_G in forum Programming
    Replies: 4
    Last Post: 09-04-2012, 03:00 PM
  4. Use Switchboard to close db AND Access
    By HeadGasket in forum Forms
    Replies: 1
    Last Post: 02-01-2012, 07:08 PM
  5. Replies: 2
    Last Post: 06-20-2011, 03:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums