Hiding Startup form

Posted on 2004-09-23
Last Modified: 2010-05-18
I have a form called frmLoginForm that when the user opens the program it checks to see if he/she is autorized to access it and if so logs their name, date and time to a table. It then opens the form frmMainMenu that gives them access to the database. I want to hide this for from the users view and run behind the scene. I have my code in the Form_Load property. The problem is the for stays visible after it opens the form frmMainMenu. Here is my code, some please give me an idea, I have tried .hide, .visible = false and nothing seems to work.

      Dim db As Database
      Dim rst As Recordset
      Dim strName As String
      Dim strSQL As String
      Set db = CurrentDb()
      Set rst = db.OpenRecordset("tblOCCTeam")
      strName = GetCurrentChangeName

      If Not rst.EOF Then
            Do While Not rst.EOF
                If strName = rst!LanID.Value Then
                        strSQL = "INSERT INTO tblRecStatus(EmployeeName,Status) " & _
                        "VALUES(" & _
                                    " '" & rst!EmployeeName.Value & " ','" & "Signed On" & "')"
                        Debug.Print strSQL
                        DoCmd.RunSQL (strSQL)
                        DoCmd.OpenForm "frmMainMenu"
                        Exit Sub
                  End If
            MsgBox "You do not have permission to access this Database, Please contact the OCC Team Supervisor if access is needed."
      End If
Question by:tkrpata
  • 2
  • 2
  • 2

Accepted Solution

JonoBB earned 250 total points
ID: 12134929
Why even have the frmLoginForm?

You can bypass using that form by calling your code above from the autoexec macro......

That way, your code above will always run automatically, and only open frmMainMenu if they are authorised...

Make sense?
LVL 17

Expert Comment

ID: 12134995
I'd agree you may not need the form.
You could use the autoexec as jono suggested OR
you could put this code in the onOpen event of the mainMenu
or why not just have
docmd.close right before docmd.openform "frmMainMenu"?


Author Comment

ID: 12135113
Didn't even think about that, works great, thanks alot..
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.


Expert Comment

ID: 12135139
No problem, glad I could help

but howcome you gave the points to waltercook? (Sorry Walter)
LVL 17

Expert Comment

ID: 12135143
Looks like you accepted the wrong one, tk.  If that's the case you can post a question in Community Support with a link to this one and have them change it.


Author Comment

ID: 12136568
Will do, thanks

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now