A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Load event question



 
 
Thread Tools Display Modes
  #1  
Old March 18th, 2010, 07:58 PM posted to microsoft.public.access.forms
Iago
external usenet poster
 
Posts: 11
Default Load event question

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

  #2  
Old March 18th, 2010, 08:56 PM posted to microsoft.public.access.forms
ghetto_banjo
external usenet poster
 
Posts: 325
Default Load event question

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

  #3  
Old March 18th, 2010, 10:19 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Load event question

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/For...forms/201003/1

  #4  
Old March 24th, 2010, 04:19 PM posted to microsoft.public.access.forms
Iago
external usenet poster
 
Posts: 11
Default Load event question

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/For...forms/201003/1

.

  #5  
Old March 24th, 2010, 10:51 PM posted to microsoft.public.access.forms
Bob Quintal
external usenet poster
 
Posts: 939
Default Load event question

=?Utf-8?B?SWFnbw==?= wrote in
:

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/For...forms/201003/1

.





--
Bob Quintal

PA is y I've altered my email address.
  #6  
Old March 25th, 2010, 02:38 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Load event question

Bob Quintal wrote:
"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."

Actually, placing this in the Form_Load event will only effect the first
record displayed, not every record!

--
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/For...forms/201003/1

  #7  
Old March 25th, 2010, 10:02 PM posted to microsoft.public.access.forms
Bob Quintal
external usenet poster
 
Posts: 939
Default Load event question

"Linq Adams via AccessMonster.com" u28780@uwe wrote in
news:a589aae4ce2b7@uwe:

Bob Quintal wrote:
"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."

Actually, placing this in the Form_Load event will only effect the
first record displayed, not every record!

If the load event places the data into an unbound box, and code in
another event writes it to the table, it will affect every row.

--
Bob Quintal

PA is y I've altered my email address.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.