Share via

Closing Hidden Form

Anonymous
2017-05-11T09:54:38+00:00

Hi, all. I am sorry if I’m asking too much here.

Situation:

I have an application with a login form. Once you press the login button the login form is hidden (visible=False) to be able to pass the user id and user rights to other forms or reports. In order to close the application the user needs to press a button in the swithcboard but that is not possible because of the hidden form.

Question: How do I activate the hidden form to close once the switchboard close application button is hit? Example where do I put the code, I need this to implement security access level properly like the one below:

If Forms!frmLogin!cboUser.Column(4) <> 2 Then

    MsgBox “You are not authorized to open this form!”, vbOkOnly +vbExclamation

    Cancel = True

End If

If the login form is not active then the above code will not work, that is why I have to hide it instead of closing it by DoCmd.Close “frmLogin”

The login form will remain open to enable the user navigate all forms or reports which he/she is authorized to until deciding to leave the app.

Regards

Chris

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. ScottGem 68,830 Reputation points Volunteer Moderator
    2017-05-11T11:47:59+00:00

    Are you using Switchboard Manager? The Exit Application option should close all forms. I'm not sure why this presents a problem for you. 

    If you are running code in the On Close event of some of your forms and this code requires the Login form be open and Exit Application doesn't close forms in the proper order, you may need to relook at the close sequence or you may need to code a close function that is called from the switchboard.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2017-05-11T12:33:23+00:00

    Yes sir your are correct I'm using a Switchboard Manager I think I have to double check how I did the other form for payroll , I have no issues there.

    Regards

    Chris

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2017-05-11T10:55:45+00:00

    But how do I do it ? the exit button is on the switchboard and works on its own ms access built macros , if it was my own built switchboard then it is easy I would have added DoCmd.Close acForm, "frmLogin" on the click exit button. Please explain properly what you are saying

    Regards

    Chris

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2017-05-11T10:45:41+00:00

    You don't need to activate the form. Just issue this call to Close when the user clicks the Exit button:

    DoCmd.Close acForm, "frmLogin"

    Was this answer helpful?

    0 comments No comments