Is the form open? It will need to be.
If not, as an alternative why not save the person whose has logged in to a local table, and look that up?
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
I thought the code went into every form in the on load args is this correct?
inserted it into the LoginForm on load args and get run time error - didn't think it went hear though just trying things out.
how do you mean by save person in to a local table? so that when someones logged in, it records the user to a table...
that would be helpful I guess but would that help the AccesslevelID problem?
the code I have working was in afterupdate I have created a login button and entered the code to use button - all works fine but when but when all forms close and login form is reopened the user and password can still be re-used hense not logged out any ideas?
Private Sub cmdEnter_Click()
'Check that EE is selected
If IsNull(Me.cboUser) Then
MsgBox "You need to select a user!", vbCritical
Me.cboUser.SetFocus
Else
'Check for correct password
If Me.txtPassword = Me.cboUser.Column(2) Then
'Check if password needs to be reset
If Me.cboUser.Column(3) = True Then
DoCmd.OpenForm "PasswordChange", , , "[EmployeeID_PK] = " & Me.cboUser
End If
DoCmd.OpenForm "CabinetTech"
Me.Visible = False
Else
MsgBox "Invalid Password!", vboOkOnly
Me.txtPassword = Null
Me.txtPassword.SetFocus
End If
End If
End Sub
Private Sub Form_Load()
Me.cboUser.SetFocus
End Sub
My suggestion if you want to store this is to have a local table - call it tblLocalSystem
Its a one row table with the current user details and any other local information stored.
Make the first field your RowID and set it as primary key, value 1 . Have a field called CurrUserID, and store the logged in user ID to this field, empty it on exiting the database.
You can then lookup this value to determine their access levels etc.
Don't store it on the login form entry boxes - simply clear those out when they have correctly logged in.
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
cheers for that Minty I managed to sort it out and have it working... what Ive done is created log out buttons on each page as well as back buttons, the log out buttons simply closes all forms even login form and then reloads which clears the user and password.My suggestion if you want to store this is to have a local table - call it tblLocalSystem
Its a one row table with the current user details and any other local information stored.
Make the first field your RowID and set it as primary key, value 1 . Have a field called CurrUserID, and store the logged in user ID to this field, empty it on exiting the database.
You can then lookup this value to determine their access levels etc.
Don't store it on the login form entry boxes - simply clear those out when they have correctly logged in.
took me some time but got there, I need to code the forms individually but its only 6-7 lines so that's fine i don't mind the experience lol