T
T
Timofey Mikhailov2019-09-16 14:20:30
Visual Basic
Timofey Mikhailov, 2019-09-16 14:20:30

Why doesn't Access see the function from the module?

The question is pretty simple.
I wrote a function in the module:

Public Function GetUserName() As String
    ' GetUserName = Environ("USERNAME")
    ' Environ("USERNAME") is easily spoofed, see comment by HansUp
    GetUserName = CreateObject("WScript.Network").UserName
End Function

What do I really need.
When creating a new row in the Table, the function should automatically write the username in the field ...
And I write in the "Default Value" section. =GetUserName()
But Access writes to me that this function does not exist ...
What's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Matveev, 2019-09-19
@ematveev

it turns out that the function is not in the scope of the executable code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question