code for opening a form

Weresmytriple

Registered User.
Local time
Today, 16:13
Joined
Sep 5, 2013
Messages
58
hi all

im currently using

Code:
Private Sub Form_Open(Cancel As Integer)
    Const cstrUserName As String = "Admin"
    Const cstrPassWord As String = "open"
    Dim strUserName As String
    If strUserName = InputBox("Username:") Then
        If strUserName = cstrUserName Then
            Dim strPassWord As String
            strPassWord = InputBox("Password:")
            If strPassWord = cstrPassWord Then
                stDocName = "Admin Switchboard"
                DoCmd.OpenForm stDocName
            Else
            
        End If
        Else
        
    End If
End Sub

as a way of protecting a form however i need the else of this statement to open the form called homepage. any idea how to do this?

thanks

michael
 
Something like..
Code:
Private Sub Form_Open(Cancel As Integer)
    Const cstrUserName As String = "Admin"
    Const cstrPassWord As String = "open"
    
    Dim strUserName As String
    
    strUserName = InputBox("Username:")
    If strUserName = cstrUserName Then
        Dim strPassWord As String
        strPassWord = InputBox("Password:")
        If strPassWord = cstrPassWord Then
            stDocName = "Admin Switchboard"
            DoCmd.OpenForm stDocName
        Else
            [COLOR=Blue]DoCmd.OpenForm "yourHomeFormName"[/COLOR]
        End If
    Else
        [COLOR=Blue]DoCmd.OpenForm "yourHomeFormName"[/COLOR]
    End If
End Sub
 
Realy seperated input boxes for Username and Password? Wouldnt it be much nicer to have both on the same form as a popup instead of the seperation?
 

Users who are viewing this thread

Back
Top Bottom