473,378 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Update of Field after Change

Hello All,

I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this autogenerated
but not sure how to make this happen. Since this over a network, the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.

Any suggestions? I'm rather new at this!

Thanks!

Aug 7 '06 #1
7 5921
Ask the system how it would like the information, since it already
knows who is in the database. I hope you speak Systemese though,
they've got awful accents which are very hard to understand.

That aside, I'd probably stick a few hidden text boxes on your form and
have them populated with the users name and todays date. Link those
text boxes back to the table the data resides in.
Colleen wrote:
Hello All,

I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this autogenerated
but not sure how to make this happen. Since this over a network, the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.

Any suggestions? I'm rather new at this!

Thanks!
Aug 7 '06 #2
Use the BeforeUpdate event procedure of the *form* to write the value to the
fields.

You can get the network user name from this link:
http://www.mvps.org/access/api/api0008.htm

Then in the BeforeUpdate event procedure of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.CreatedBy = fOSUserName()
Else
Me.UpdatedBy = fOSUserName()
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleen" <te*************@frontiernet.netwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Hello All,

I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this autogenerated
but not sure how to make this happen. Since this over a network, the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.

Any suggestions? I'm rather new at this!

Thanks!

Aug 8 '06 #3
Thanks!

I followed the procedure and when I attempted to use it I get the
following:

Compile Error: expected variable or procedure, not module.

When I click ok, fOSUsername on created by is highlighted.

I've never worked with these before, any suggestions?
Allen Browne wrote:
Use the BeforeUpdate event procedure of the *form* to write the value to the
fields.

You can get the network user name from this link:
http://www.mvps.org/access/api/api0008.htm

Then in the BeforeUpdate event procedure of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.CreatedBy = fOSUserName()
Else
Me.UpdatedBy = fOSUserName()
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleen" <te*************@frontiernet.netwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Hello All,

I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this autogenerated
but not sure how to make this happen. Since this over a network, the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.

Any suggestions? I'm rather new at this!

Thanks!
Aug 8 '06 #4
Sounds like you named the module with the same name as the procedure.

If so, rename to module to something else, such as Module1.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleen" <te*************@frontiernet.netwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Thanks!

I followed the procedure and when I attempted to use it I get the
following:

Compile Error: expected variable or procedure, not module.

When I click ok, fOSUsername on created by is highlighted.

I've never worked with these before, any suggestions?
Allen Browne wrote:
>Use the BeforeUpdate event procedure of the *form* to write the value to
the
fields.

You can get the network user name from this link:
http://www.mvps.org/access/api/api0008.htm

Then in the BeforeUpdate event procedure of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.CreatedBy = fOSUserName()
Else
Me.UpdatedBy = fOSUserName()
End If
End Sub

"Colleen" <te*************@frontiernet.netwrote in message
news:11*********************@m73g2000cwd.googlegr oups.com...
Hello All,

I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this autogenerated
but not sure how to make this happen. Since this over a network, the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.

Aug 8 '06 #5
Boy Doggies I sure am learning things today! I really appreciate your
help!

I renamed the module, I had named it fOSUserName (duh!). Anyway, I now
get run-time error 2465-Microsoft Access can't find the field
'NewRecord' referred to in your expression. This is the code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me!NewRecord Then
Me!CreatedBy = fOSUserName()
Else
Me!UpdatedBy = fOSUserName()
Me!DateLastAccessed = Now()
End If
End Sub

Suggestions?
Allen Browne wrote:
Sounds like you named the module with the same name as the procedure.

If so, rename to module to something else, such as Module1.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleen" <te*************@frontiernet.netwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Thanks!

I followed the procedure and when I attempted to use it I get the
following:

Compile Error: expected variable or procedure, not module.

When I click ok, fOSUsername on created by is highlighted.

I've never worked with these before, any suggestions?
Allen Browne wrote:
Use the BeforeUpdate event procedure of the *form* to write the value to
the
fields.

You can get the network user name from this link:
http://www.mvps.org/access/api/api0008.htm

Then in the BeforeUpdate event procedure of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.CreatedBy = fOSUserName()
Else
Me.UpdatedBy = fOSUserName()
End If
End Sub

"Colleen" <te*************@frontiernet.netwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Hello All,

I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this autogenerated
but not sure how to make this happen. Since this over a network, the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.
Aug 8 '06 #6
NewRecord is a property: you need to use a dot (not a bang) for properties:

If Me.NewRecord Then

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleen" <te*************@frontiernet.netwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Boy Doggies I sure am learning things today! I really appreciate your
help!

I renamed the module, I had named it fOSUserName (duh!). Anyway, I now
get run-time error 2465-Microsoft Access can't find the field
'NewRecord' referred to in your expression. This is the code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me!NewRecord Then
Me!CreatedBy = fOSUserName()
Else
Me!UpdatedBy = fOSUserName()
Me!DateLastAccessed = Now()
End If
End Sub

Suggestions?
Allen Browne wrote:
>Sounds like you named the module with the same name as the procedure.

If so, rename to module to something else, such as Module1.

"Colleen" <te*************@frontiernet.netwrote in message
news:11**********************@m73g2000cwd.googleg roups.com...
Thanks!

I followed the procedure and when I attempted to use it I get the
following:

Compile Error: expected variable or procedure, not module.

When I click ok, fOSUsername on created by is highlighted.

I've never worked with these before, any suggestions?
Allen Browne wrote:
Use the BeforeUpdate event procedure of the *form* to write the value
to
the
fields.

You can get the network user name from this link:
http://www.mvps.org/access/api/api0008.htm

Then in the BeforeUpdate event procedure of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.CreatedBy = fOSUserName()
Else
Me.UpdatedBy = fOSUserName()
End If
End Sub

"Colleen" <te*************@frontiernet.netwrote in message
news:11*********************@m73g2000cwd.googlegr oups.com...
Hello All,

I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this
autogenerated
but not sure how to make this happen. Since this over a network,
the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.

Aug 9 '06 #7
Thanks again!

It works wonderfully!

You're Awesome!
Colleen wrote:
Boy Doggies I sure am learning things today! I really appreciate your
help!

I renamed the module, I had named it fOSUserName (duh!). Anyway, I now
get run-time error 2465-Microsoft Access can't find the field
'NewRecord' referred to in your expression. This is the code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me!NewRecord Then
Me!CreatedBy = fOSUserName()
Else
Me!UpdatedBy = fOSUserName()
Me!DateLastAccessed = Now()
End If
End Sub

Suggestions?
Allen Browne wrote:
Sounds like you named the module with the same name as the procedure.

If so, rename to module to something else, such as Module1.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleen" <te*************@frontiernet.netwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Thanks!
>
I followed the procedure and when I attempted to use it I get the
following:
>
Compile Error: expected variable or procedure, not module.
>
When I click ok, fOSUsername on created by is highlighted.
>
I've never worked with these before, any suggestions?
>
>
Allen Browne wrote:
>Use the BeforeUpdate event procedure of the *form* to write the value to
>the
>fields.
>>
>You can get the network user name from this link:
> http://www.mvps.org/access/api/api0008.htm
>>
>Then in the BeforeUpdate event procedure of the form:
>>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> If Me.NewRecord Then
> Me.CreatedBy = fOSUserName()
> Else
> Me.UpdatedBy = fOSUserName()
> End If
> End Sub
>>
>"Colleen" <te*************@frontiernet.netwrote in message
>news:11*********************@m73g2000cwd.googlegr oups.com...
Hello All,
>
I have a table for my employee data. I have a field that generates
date before update of latest changes made. I also have two fields
within called CreatedBy and UpdatedBy. I would like this autogenerated
but not sure how to make this happen. Since this over a network, the
system knows who is creating and working within a database, I'm at a
loss as to how I point to this to update the field.
Aug 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bill Clark | last post by:
I have about 20,000 records pulled from Excel that I need to update. What I need to do is run an update query that bascially says: If a field is null, update it with the previous record value of...
33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
4
by: N. Graves | last post by:
Hello... thank you for your time. I have a form that has a List box of equipotent records and a sub form that will show the data of the equipment select from the list box. Is it possible to...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
7
by: gthompson | last post by:
Is this possible: Read fields(rows/columns) from one sql database table (TableA). Then edit/update the same 'field' in TableA; and in TableB edit/update a different field - all at the same time?...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
6
by: Dixie | last post by:
I have asked this question before, but I could not get the suggested solution work. So I will give more details this time. I have an append query that adds several hundred records to a table...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
3
by: fperri | last post by:
I have a field in my main table called "CHANGE". Each week before we update the data we create a backup of the table and adjust the CHANGE field for all records to zero. I have an update query where...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.