Hi,
Ok, so what I am aiming for is to automatically pop-up the username of the person who is adding data into the database. I created a table "tblCurrentlyLoggedIn" and Field Name is "empCurrentlyLoggedIn". For my Data Entry button, I put this:
Private Sub Form_Close()
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM tblCurrentlyLoggedIn WHERE empCurrentlyLoggedIn = fOSUserName()"
DoCmd.SetWarnings True
'Application.CompactRepair Application.CurrentDb.Name, Application.CurrentDb.Name
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblCurrentlyLoggedIn ( empCurrentlyLoggedIn ) " & _
"SELECT fOSUserName() AS Users;"
DoCmd.SetWarnings True
End Sub
When I tested it and clicked the Data Entry button, I got an error message "Run time error '3085': Undefined function 'fOSUserName' in expression. What did I miss?![]()