From: Iago on
I found this code along with it's function on this discussion group. It works
great but I want it to populate the text field when the form loads.
How can I get the following code on the Form_Load()?
fOSUserName() is a defined function.

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo BeforeUpdate_Err

' Set bound controls to system date and time and current user name
Me.DateModified = Now()
Me.ModifiedBy = fOSUserName()

BeforeUpdate_End:
Exit Sub
BeforeUpdate_Err:
MsgBox Err.Description, vbCritical & vbOKOnly, _
"Error Number " & Err.Number & " Occurred"
Resume BeforeUpdate_End
End Sub

From: ghetto_banjo on
You should be able to just copy the same code into the On Load event.

Private Sub Form_Load()

Me.DateModified = Now()
Me.ModifiedBy = fOSUserName()

End Sub

From: Linq Adams via AccessMonster.com on
What is your point in placing it in the Load event? This will only cause the
fields in the first record that loads to be changed, and what if that record
isn't actually modified? It will now have erroneous information.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201003/1

From: Iago on
The 'modifiedby' field is what I found on the forum, my field is actually
called 'User' and I am using it to capture what user is entering data into
the form. I want it to populate automatically when the user opens the form.

"Linq Adams via AccessMonster.com" wrote:

> What is your point in placing it in the Load event? This will only cause the
> fields in the first record that loads to be changed, and what if that record
> isn't actually modified? It will now have erroneous information.
>
> --
> There's ALWAYS more than one way to skin a cat!
>
> Answers/posts based on Access 2000/2003
>
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201003/1
>
> .
>
From: Bob Quintal on
=?Utf-8?B?SWFnbw==?= <Iago(a)discussions.microsoft.com> wrote in
news:50FA36E3-2AA8-45ED-9B37-0E5068C56F8D(a)microsoft.com:

> The 'modifiedby' field is what I found on the forum, my field is
> actually called 'User' and I am using it to capture what user is
> entering data into the form. I want it to populate automatically
> when the user opens the form.
>
I think you really would want it to save the user when the user
actually updates the information in the form to the table. To do that
use the Form's Before_Update Event.

Using the Load event means that EVERY user will be shown as the USER
in EVERY ROW that is looked at, as well as the ones that do get new
data entered..

I'm sure that's not what you really want.

as to the different field name, just change me.ModifiedBy to me.User

Bob Q




> "Linq Adams via AccessMonster.com" wrote:
>
>> What is your point in placing it in the Load event? This will
>> only cause the fields in the first record that loads to be
>> changed, and what if that record isn't actually modified? It
>> will now have erroneous information.
>>
>> --
>> There's ALWAYS more than one way to skin a cat!
>>
>> Answers/posts based on Access 2000/2003
>>
>> Message posted via AccessMonster.com
>> http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201003/1
>>
>> .
>>
>



--
Bob Quintal

PA is y I've altered my email address.
 |  Next  |  Last
Pages: 1 2
Prev: Forcing New Page
Next: nested iif statements in a query