How to fill auto username when someone created the form

Wynna

New member
Local time
Today, 13:05
Joined
Mar 21, 2016
Messages
3
Hi Guys,, I am new here & quite struggling using Microsoft Access.

Basically, I want do report in Microsoft Access with auto fill name "who created the column"

Example like:

Date
Case
Created by (This one will auto fill if someone created a case)

Can someone help me,,
 
You can try this. Paste this function code into a module:
Code:
Public Function Username()
    Username = Environ("username")
End Function

Then in the default value for the user text box, enter:
=Username()
 
Hi Stopher,

Its show unknown function "Username" in validation expression or default value on Test.Created by.

Please help, thanks :)
 
is this on report, try the Load event:

private sub report_load()
' if it is a textbox
me.yourControl = Environ("UserName")

'if it is a label
'me.yourControl.Caption = "Created by: " & Environ("UserName")
End Sub
 
Arnelgp and Stopher are showing you the right thing, but you need to know that the best place to call the Environ function is in VBA code. The "properties" section on any control is not always VBA-friendly. For instance, validation criteria are limited in what they will do. Default value, ditto.

I usually put this kind of code in a text box Lost_Focus routine, so what happens is if the user tabs through the text box without putting in a name, I use the indicated function. You could also do this on the form's BeforeUpdate routine (not the control's routine) or you could take the issue completely out of the user's hands by hiding the control and doing an automatic insert in the Form_Current routine.

If you leave it to your users, they will forget, which is why I use the Form_Current code.
 
Oohh no, i am really struggling when use all formula in above :( can someone help me to create the form, so i know how to do it? :(
 

Users who are viewing this thread

Back
Top Bottom