Okay, have my suggestions helped?
You need to:
1. determine who the current user is - by having them provide ID or you grab from network with Environ("USERNAME")
2. search the table to find credentials for that user for Neon Impact
3. if no credentials then create new record
4. continue login with the new credentials
Code in my project - login form opens by default and Load event calls Sub UserLogin. If the user is already in table then the Menu form opens and Login closes, otherwise Login remains open for user input of initials and then a record is created and UserLogin is called again:
Code:
Private Sub Form_Load()
UserLogin
End Sub
Private Sub UserLogin()
Me.tbxUser = DLookup("UserInitials", "Users", "UserNetworkID='" & Environ("UserName") & "'")
If Not IsNull(Me.tbxUser) Then
CurrentDb.Execute "UPDATE Users SET ComputerName='" & VBA.Environ("ComputerName") & "' WHERE UserInitials='" & Me.tbxUser & "'"
DoCmd.OpenForm "Menu", acNormal, , , , acWindowNormal, Me.tbxUser
DoCmd.Close acForm, Me.Name, acSaveNo
End If
End Sub
Private Sub tbxUser_AfterUpdate()
If Me.tbxUser Like "[A-Z][A-Z][A-Z]" Or Me.tbxUser Like "[A-Z][A-Z]" Then
CurrentDb.Execute "INSERT INTO Users(UserNetworkID, UserInitials, Permissions) VALUES('" & VBA.Environ("UserName") & "', '" & UCase(Me.tbxUser) & "', 'staff')"
Call UserLogin
Else
MsgBox "Not an appropriate entry.", vbApplicationModal, "EntryError"
End If
End Sub