Results 1 to 2 of 2
  1. #1
    pervezahmed is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    8

    Login form

    I have a database of Inventory management. I created a login form for this login form i have made a module on Access vb the code is






    Option Compare Database

    Global Const SW_HIDE = 0
    Global Const SW_SHOWNORMAL = 1
    Global Const SW_SHOWMINIMIZED = 2
    Global Const SW_SHOWMAXIMIZED = 3


    Private Declare Function apiShowWindow Lib "user32" _
    Alias "ShowWindow" (ByVal hwnd As Long, _
    ByVal nCmdShow As Long) As Long

    Function fSetAccessWindow(nCmdShow As Long)
    'Usage Examples
    'Maximize window:
    ' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
    'Minimize window:
    ' ?fSetAccessWindow(SW_SHOWMINIMIZED)
    'Hide window:
    ' ?fSetAccessWindow(SW_HIDE)
    'Normal window:
    ' ?fSetAccessWindow(SW_SHOWNORMAL)
    '
    Dim loX As Long
    Dim loForm As Form
    On Error Resume Next
    Set loForm = Screen.ActiveForm
    If Err <> 0 Then 'no Activeform
    If nCmdShow = SW_HIDE Then
    MsgBox "Cannot hide Access unless " _
    & "a form is on screen"
    Else
    loX = apiShowWindow(hWndAccessApp, nCmdShow)
    Err.Clear
    End If
    Else
    If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
    MsgBox "Cannot minimize Access with " _
    & (loForm.Caption + " ") _
    & "form on screen"
    ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
    MsgBox "Cannot hide Access with " _
    & (loForm.Caption + " ") _
    & "form on screen"
    Else
    loX = apiShowWindow(hWndAccessApp, nCmdShow)
    End If
    End If
    fSetAccessWindow = (loX <> 0)

    End Function

    '************ Code End **********



    This module code saved with the name of basHideAccessWindow
    but the global code is not deleted.


    On form i have applied the code



    Private Sub cmdExit_Click() ( this code is for Exit button on the login form)
    On Error GoTo ErrorPoint

    DoCmd.Quit

    ExitPoint:
    Exit Sub

    ErrorPoint:
    MsgBox "The following error has occurred:" _
    & vbNewLine & "Error Number: " & Err.Number _
    & vbNewLine & "Error Description: " & Err.Description _
    , vbExclamation, "Unexpected Error"
    Resume ExitPoint
    End Sub

    Private Sub cmdLogin_Click() ( this code is for Login button on the login form)
    'Check to see if data is entered into the UserName combo box

    If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
    Me.cboEmployee.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("strEmpPassword", "tblEmployees", _
    "[lngEmpID]=" & Me.cboEmployee.Value) Then

    lngMyEmpID = Me.cboEmployee.Value

    'Close logon form and open splash screen

    DoCmd.Close acForm, "Login", acSaveNo
    DoCmd.OpenForm "Splash"

    Else
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
    "Invalid Entry!"
    Me.txtpassword.SetFocus
    End If

    'If User Enters incorrect password 3 times database will shutdown

    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
    End Sub

    Private Sub Form_Open(Cancel As Integer) ( this code is for Login form on open expression on the login form)
    On Error GoTo ErrorPoint

    Me.Visible = True
    fSetAccessWindow (SW_HIDE)

    ExitPoint:
    Exit Sub

    ErrorPoint:
    MsgBox "The following error has occurred:" _
    & vbNewLine & "Error Number: " & Err.Number _
    & vbNewLine & "Error Description: " & Err.Description _
    , vbExclamation, "Unexpected Error"
    Resume ExitPoint
    End Sub


    Dear sir,, I just hear that with this code i can hide the acces window when i open the login form....only login form////
    after successful login it will onen the splash window........
    But the problem is...the things is working coreectly ,, no error shows...
    When i input user name and pasword.....the login form close but no form is opened...and i can not open the database file once. After restart..it open....
    Why this happens///please help me....Or if you have any other option please let me know...
    Thank you,,,
    Pervez ahmed,

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Sounds like to me you have it closing before it opens your other form! The OpenForm code will have to be before the CloseForm Code.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Login Form
    By data808 in forum Forms
    Replies: 1
    Last Post: 08-23-2012, 04:48 PM
  2. Login Form
    By bnar in forum Security
    Replies: 11
    Last Post: 07-24-2012, 03:11 AM
  3. Replies: 1
    Last Post: 12-11-2011, 11:48 AM
  4. Login form with nt login
    By hitesh_asrani_j in forum Forms
    Replies: 6
    Last Post: 09-22-2011, 11:43 AM
  5. Login to a form?
    By tandkb in forum Forms
    Replies: 0
    Last Post: 04-25-2011, 06:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums