Steve@trop
Registered User.
- Local time
- Today, 05:03
- Joined
- May 10, 2013
- Messages
- 148
Our company uses ID numbers instead of names as the Network Login ID. I have a user-defined function that uses the LoginID as the default in a field on my form. The code is below:
Public Function LoginName()
LoginName = CreateObject("wscript.network").UserName
End Function
I just put =LoginName() in the default and it does the trick. Unfortunately, that isn't as useful as it should be because it returns a number instead of a name. I have a table (OperatorT) with the FullName and UserID and I'd like to have the default be the full name instead of the number.
I've tried several ways of putting in the expression in the default field but it keeps telling me that the syntax is incorrect. I came close to what I want by putting this query in the RowSource:
SELECT OperatorT.FullName FROM OperatorT WHERE (((OperatorT.UserID)=LoginName()));
This puts the numerical ID in the field but if you click on it, the FullName appears in a drop-down when you click it. This makes me think I'm close but am missing something simple. I'd like to have it skip the ID and put in the name instead. Perhaps I need to put something in the Event tab?
Thanks,
Steve
Public Function LoginName()
LoginName = CreateObject("wscript.network").UserName
End Function
I just put =LoginName() in the default and it does the trick. Unfortunately, that isn't as useful as it should be because it returns a number instead of a name. I have a table (OperatorT) with the FullName and UserID and I'd like to have the default be the full name instead of the number.
I've tried several ways of putting in the expression in the default field but it keeps telling me that the syntax is incorrect. I came close to what I want by putting this query in the RowSource:
SELECT OperatorT.FullName FROM OperatorT WHERE (((OperatorT.UserID)=LoginName()));
This puts the numerical ID in the field but if you click on it, the FullName appears in a drop-down when you click it. This makes me think I'm close but am missing something simple. I'd like to have it skip the ID and put in the name instead. Perhaps I need to put something in the Event tab?
Thanks,
Steve