Login Form (1 Viewer)

spectrolab

Registered User.
Local time
Today, 21:40
Joined
Feb 9, 2005
Messages
116
Hi Everyone,

I have a bit of a question, I'm not sure if it even possbile after many hours of searching. I have the following LOGIN Form code:

Code:
Private Sub cmdLogin_Click()

Dim strUser As String
Dim strPWD As String
Dim intUSL As Integer

'Check to see if data is entered into the UserName combo box

    If IsNull(Me.cboEmpID) Or Me.cboEmpID = "" Then
      MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
        Me.cboEmpID.SetFocus
    '   Exit Sub
    End If

    'Check to see if data is entered into the password box

    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
      MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
        Me.txtPassword.SetFocus
        Exit Sub
    End If

    'Check value of password in tblEmployees to see if this
    'matches value chosen in combo box

    If Me.txtPassword.Value = DLookup("Password", "tblEmployees", _
            "[EmpID]=" & Me.cboEmpID.Value) Then

        strUser = Me.cboEmpID.Value
        intUSL = DLookup("[SecurityGroup]", "tblEmployees", "[EmpID]=" & Me.cboEmpID.Value)
        Forms!frmUSL.txtUN = strUser
        Forms!frmUSL.txtUSL = intUSL
        Select Case intUSL
            Case 1
                DoCmd.OpenForm "frmLIMSMainMenu", acNormal
            Case 2
                DoCmd.OpenForm "frmLIMSMainMenu", acNormal
                Forms![frmLIMSMAinMenu]![cmdRunningTotals].Visible = False
            Case 3
                DoCmd.OpenForm "frmLIMSMainMenu", acNormal
                Forms![frmLIMSMAinMenu]![cmdRunningTotals].Visible = False
                Forms![frmLIMSMAinMenu]![cmdRemove].Visible = False
            
        End Select
        DoCmd.Close acForm, "frmLogin", acSaveNo
    
Else
      MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
            "Invalid Entry!"
     
        
     Me.txtPassword.SetFocus
     End If
     intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
      MsgBox "You do not have access to this database.Please contact admin.", _
               vbCritical, "Restricted Access!"
        Application.Quit
    End If

It was put together from a quite a few posts and a lot of trial and error.

What I want to do is for Case 3, the lowest access level, is to automatically hide the navigation pane (Access 2007) but leave it available for Access levels 1 and 2. I know how to hide it in a ACCDE, but then it isn't available to the people who need it.

Is there someway this can be done in VBa?

Many thanks for any help.

Nigel
 

ajetrumpet

Banned
Local time
Today, 08:40
Joined
Jun 22, 2007
Messages
5,638
hiding the nav. pane in Access 2007 can be done with the F11 key. Maybe you can use the SENDKEYS function to do this with the 3rd case statement...???
Code:
sendkeys "{F11}"
 

boblarson

Smeghead
Local time
Today, 06:40
Joined
Jan 12, 2001
Messages
32,059
Here - courtesy of Brent Spaulding:

To show the nav pane:
Code:
Public Sub UnHideNavPane()    
   DoCmd.SelectObject acTable, "MSysObjects", True
End Sub

To Hide the nav pane:
Code:
Public Sub HideNavPane()    
   DoCmd.SelectObject acTable, "MSysObjects", True    
   DoCmd.RunCommand acCmdWindowHide
End Sub
 

spectrolab

Registered User.
Local time
Today, 21:40
Joined
Feb 9, 2005
Messages
116
Thanks Bob (and Brent)

Do you happen to know which references need to be set for this? It isn't working at the moment and comes up with:

Can not find the object "MSysObjects" you referenced.

Any ideas?


I tried "UsysRibbons" as well, still no luck
 
Last edited:

boblarson

Smeghead
Local time
Today, 06:40
Joined
Jan 12, 2001
Messages
32,059
Can not find the object "MSysObjects" you referenced.
Are you saying YOU can't find it or that you are getting an error while using it? MSysObjects exists in EVERY database - it is a system table so it is not visible unless you set an option for it to be visible.

You can possibly just modify it to this:

Code:
Public Sub UnHideNavPane()    
   DoCmd.SelectObject acTable, , True
End Sub

Code:
Public Sub HideNavPane()    
   DoCmd.SelectObject acTable, , True    
   DoCmd.RunCommand acCmdWindowHide
End Sub
 

spectrolab

Registered User.
Local time
Today, 21:40
Joined
Feb 9, 2005
Messages
116
Thanks Bob,

Your suggestion works perfectly, very strange.

I should have put the full error I was getting, I can find the table, it is hidden in the Nav Pane

I get this error:

Run-time error "2544"

Database can't Find the MSysObjects you referenced in the Object Name argument.

The system tables are hidden by default in the Nav Pane, could that be why it can't find them?
 

hotciats

New member
Local time
Today, 21:40
Joined
Oct 17, 2010
Messages
5
hello experts! does anyone knows how to make a login form without using combo box in the username field?
 

Users who are viewing this thread

Top Bottom