This implementation is easy. Set up a table with the following fields:
Code:
User ID (Number or Autonumber, required
and must be unique)
User Name (Text)
Connected (Yes/No)
When the user connects, open a small form with an unbound combo box that uses this table as its source. The linked field in the combo box is the User ID The user selects their name and clicks on a "Done" or "Log-in" button.
There are a couple of opens for the functionality of the "Done" button.
1) The Done button can hide the login form. When you need to access the User ID for insertion into a table/form for tracking changes, just reference the hidden form. If you want to be able to tell who is logged into the system, you should also have the Done button access the Users table, find the record for the current user and set the Connected field to True. In the OnClose event for the hidden form, set the Connected field to False.
2) This method is slightly more work, but I think a more elegant solution. Create a module with a private variable UserID, and Set_UserID (Integer) Sub and Get_UserID Function. In the Done button on your form, call the Set_UserID function with the user id. Whenever you need the user ID, just call the Get_UserID function. In a multiuser environment, these variables will be unique for each instance of the application, so you dont need to worry about that. You'll still need to set the Connected field to True in the Done button event and figure out what event to use to set it to False when the user is closing the application.
Let me know if this is helpful
Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt