Can I use GetNTUser as a default value

homer2002

Registered User.
Local time
Today, 19:23
Joined
Aug 27, 2002
Messages
152
I have a module with the function GetNTUSer in it.

It would be really handy if I could set the default value of a field in a table to this, but whenever I try to, I just get an error message.

Is it possible to set GetNTUser as the default value of a field?


Cheers Homer
 
I get this error message when I try to save the table

Unknown function in 'GetNTUser' in validation expresion or default value on table1.field1



I have this code in a module (and no other modules or functions or anything)



_________________________________________________

Option Compare Database
Option Explicit

Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


Public Function GetNTUser() As String
'Returns the network login name
Dim strUserName As String
'Create a buffer
strUserName = String(100, Chr$(0))
'Get user name
GetUserName strUserName, 100
'Strip the rest of the buffer
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
GetNTUser = strUserName
End Function


____________________________________________________
 
I do not think that you can use a custom function as the default value for a field in a table.

You can do it in the form where you want the default value for a combo box or text box, etc.

HTH
 

Users who are viewing this thread

Back
Top Bottom