Hide Form (1 Viewer)

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Hello,
For my db, I have created a form which I use as a kind of login screen that has a combo from which users select their name. Once selected, a command opens the main form.

DoCmd.OpenForm "FrmMenu", acNormal, "", "", , acNormal
DoCmd.Maximize

Since most other forms in the db have a reference to this combo by displaying the users name and saving it when records are added or changed I would like to add a code that keeps the login from either minimized or hidden, simply a way that users cannot close it.

Thank you for any help you can provide.
 

bob fitz

AWF VIP
Local time
Today, 03:37
Joined
May 23, 2011
Messages
4,718
Try:
Code:
DoCmd.OpenForm "FrmMenu", acNormal, "", "", , acNormal

DoCmd.Maximize

Forms!NameOfFormToHide.Visible = False
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Hello,
I have added your code, but all forms seem to disappear, as if the hide function prevents to view the frmMenu.
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Private Sub cboLogIn_Change()
DoCmd.Echo False, ""
DoCmd.OpenForm "FrmMenu", acNormal, "", "", , acNormal
DoCmd.Maximize
Forms!login.Visible = True
End Sub
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Sorry forgot to say that the login is a pop up form and the frmMenu has a normal view. Thank you
 

bob fitz

AWF VIP
Local time
Today, 03:37
Joined
May 23, 2011
Messages
4,718
Forms!login.Visible = True
should be:
Forms!login.Visible = False
I wouldn't have login as a pop up.
 

Dreamweaver

Well-known member
Local time
Today, 03:37
Joined
Nov 28, 2005
Messages
2,466
All my templates use a hidden form once a user logs in you could download them Here

The time and billing "Project" Being the last one

mick
 

isladogs

MVP / VIP
Local time
Today, 03:37
Joined
Jan 14, 2017
Messages
18,209
Another approach is to save the user name as a global variable (or a tempvar) so its value remains available to the database whilst it remains open.
If you do that, the login form can be closed rather than just hidden
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Another approach is to save the user name as a global variable (or a tempvar) so its value remains available to the database whilst it remains open.
If you do that, the login form can be closed rather than just hidden
Thanks. But would not know how to write such a code.
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
All my templates use a hidden form once a user logs in you could download them Here

The time and billing "Project" Being the last one

mick
Thanks. Got an error while trying to download. Will have to try tomorrow.
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Have you tried the code I gave you in post #7
Yes, made all the changes as suggest but the login does not hide and the frmMenu does not show up. Strange
 

bob fitz

AWF VIP
Local time
Today, 03:37
Joined
May 23, 2011
Messages
4,718
Yes, made all the changes as suggest but the login does not hide and the frmMenu does not show up. Strange
Where do you have the code and have you checked that the code does actually run
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Hi, the code is in the AfterUpdate Event. The code does run without the Forms!Login.visible = True line. It works also if I put it in the OnChange event (without the hide line).

Private Sub cboLogIn_AfterUpdate()
DoCmd.Echo False, ""
DoCmd.OpenForm "FrmMenu", acNormal, "", "", , acNormal
DoCmd.Maximize
Forms!login.Visible = True
End Sub
 

bob fitz

AWF VIP
Local time
Today, 03:37
Joined
May 23, 2011
Messages
4,718
:unsure: Why do you keep using the line:
Forms!login.Visible = True

This makes the form visible

As I've stated before, this line needs to be:
Forms!login.Visible = FALSE
 

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Sorry, my type. I did change the code to false but still getting the same problem. I cannot view any form.
By the way, I created a similar macro and converted it to VB. It's the only way works (although not the correct way)

DoCmd.Echo False, ""
DoCmd.OpenForm "LogIn", acNormal, "", "", , acNormal
DoCmd.Minimize
DoCmd.OpenForm "frmMenu", acNormal, "", "", , acNormal
DoCmd.Maximize
DoCmd.SelectObject acForm, "Login", True
DoCmd.Minimize
 

bob fitz

AWF VIP
Local time
Today, 03:37
Joined
May 23, 2011
Messages
4,718
Remove the line:
DoCmd.Echo False, ""

or Add:
DoCmd.Echo True, ""

as the last line of code
 
Last edited:

JPR

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 23, 2009
Messages
192
Finally works!!! Thank for your help.
 

Users who are viewing this thread

Top Bottom