I'm trying to use VBA to populate a field whenever a new record is being submitted. I have dataentry set to yes so a new record appears each time the form is opened, but I can only get the username to populate with
Private Sub Form_Load().
Me.Submitter = CreateObject("WScript.Network").UserName
End Sub
The username appears right the very first time obviously, but after the last field, you hit TAB and a new record starts, but with no username. Do I need to force the form to close and reopen after every new record? Or is there something I'm missing.
Thanks in advance
Well that was a short lived question. By messing around I found that when you use Dirty instead of Load it works.
Private Sub Form_Dirty(Cancel As Integer)
Me.Submitter = CreateObject("WScript.Network").UserName
Debug.Print Me.Submitter
End Sub
I even put the Debug.Print in there to make sure it wasn't constantly looking to repopulate that field with each keystroke or changing of fields, and it does not. As soon as I open the form and start entering data, that first keystroke populates my username and it's done until the next record.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With