I have a database with two tables
First table which is the login table with table name tbl_login with fields:
FirstName, LastName, UserName, Password, access_level
the 2nd table which records my data with table name INCOME_TABLE with fields
DATE, TYPE OF INCOME/EXPENSE, REVENUE
i will like to create a new field in INCOME_TABLE with the name USERNAME which will capture the username of the logged inn user against any entry made in INCOME_TABLE.
Thee are the codes i used for the login
#
Dim FIRST_NAME As Variant, access_level As Variant
If Trim(Me.txt_username.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Username should not be left blank.", buttons:=vbExclamation, title:="SOFTWARE"
Me.txt_username.SetFocus
Exit Sub
End If
If Trim(Me.txt_password.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Password should not be left blank.", buttons:=vbExclamation, title:="SOFTWARE"
Me.txt_password.SetFocus
Exit Sub
End If
' RETREIVE FROM SAVED QUERY
' ASSUMES EVERY USER GIVEN A NON-NULL ACCESS LEVEL
FIRST_NAME = DLookup("FirstName", "access1")
access_level = DLookup("access_level", "access1")
If IsNull(FIRST_NAME) = True Then
MsgBox prompt:="Incorrect username/password. Try again.", buttons:=vbCritical, title:="SOFTWARE"
Me.txt_username.SetFocus
Else
MsgBox prompt:="Welcome, " & FIRST_NAME & ".", buttons:=vbOKOnly, title:="SOFTWARE"
' CONDITIONALLY OPEN FORMS
Select Case access_level
Case "Administrator"
DoCmd.OpenForm "SYSTEM"
DoCmd.Close acForm, "frm_login", acSaveYes
Case "Accounts"
DoCmd.OpenForm "Accounts"
DoCmd.Close acForm, "frm_login", acSaveYes
Case "Secretary"
DoCmd.OpenForm "Secretary"
DoCmd.Close acForm, "frm_login", acSaveYes
End Select
End If
End Sub
#
Any help with this will be greatly appreciated