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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|