Results 1 to 6 of 6
  1. #1
    zdjbel is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    42

    Add a date when a change is made to an option group on a subform

    I have a subform with a 12 button option group, each button denoting a stage in a work process. The table to which the subform it is bound includes a DateLastUpdated field. I would like the system to insert the date into the DateLastUpdated field whenever a user changes the status in the work process, i.e. changes the selection in the option group. It would also be nice if I can pull the user's name from the system/network and store it in a seperate field, e.g. UpdatedBy. How can I do this?

    Thanks!

  2. #2
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Quick references you can use

    1) Generally, I like to get the user's ID when the user logs on, and store it in either a hidden form, a global variable, or a temp variable (depending on Access version) for just such an occasion.

    Here's a thread with some code on how to get information about your user and his/her machine. https://www.accessforums.net/access/...ers-36612.html


    2) Language is tricky around here. I believe you want to update the existing table record by changing two fields to have the two new values - the "last updated" and the "updated by" fields. The word "Insert" will get you instructions on how to add another record to the same table, which may not be the result you really want.

    The general syntax for updating a set of records on a table is
    Code:
    UPDATE MyTable
    SET Field1 = NewValue, Field2 = NewValue2
    WHERE (Field3 = "X");
    This will update all records on MyTable where Field3 = 'X".

    Now, you have to make sure that your WHERE clause uniquely defines the records that should be updated. Presumably you have a key field, and you'd use that to identify the record.


    You can generally use the Now() or Date() functions to get the current date/time for your timestamp.


    If you prefer macros, I don't know how you'd get the user ID, but you'd use something like the instructions on this page to update the current record with your timestamp and your user id. http://answers.microsoft.com/en-us/o...0-5bb268ad14a2

  3. #3
    zdjbel is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    42

    Add a date when a change is made to an option group on a subform

    Quote Originally Posted by Dal Jeanis View Post
    1) Generally, I like to get the user's ID when the user logs on, and store it in either a hidden form, a global variable, or a temp variable (depending on Access version) for just such an occasion.

    Here's a thread with some code on how to get information about your user and his/her machine. https://www.accessforums.net/access/...ers-36612.html


    2) Language is tricky around here. I believe you want to update the existing table record by changing two fields to have the two new values - the "last updated" and the "updated by" fields. The word "Insert" will get you instructions on how to add another record to the same table, which may not be the result you really want.

    The general syntax for updating a set of records on a table is
    Code:
    UPDATE MyTable
    SET Field1 = NewValue, Field2 = NewValue2
    WHERE (Field3 = "X");
    This will update all records on MyTable where Field3 = 'X".

    Now, you have to make sure that your WHERE clause uniquely defines the records that should be updated. Presumably you have a key field, and you'd use that to identify the record.


    You can generally use the Now() or Date() functions to get the current date/time for your timestamp.


    If you prefer macros, I don't know how you'd get the user ID, but you'd use something like the instructions on this page to update the current record with your timestamp and your user id. http://answers.microsoft.com/en-us/o...0-5bb268ad14a2

    Thanks very much Dal. The solution with the macro worked just fine, I wasn't aware that macros can be used in tables. As for getting and storing the user who updated the data, the link offers a solution for split databases, or so I believe. Splitting my database is in my plans once I'm satisfied with what it does. In the meantime, I'll keep searching for a solution more suited to my database and skill level, which is not very high.

    Thank you again, I am grateful and appreciate your taking time to help me out.

    Zoran

  4. #4
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    I don't believe there is a difference between the method you'd use to log the user on a split versus a combined database. The only difference between split and unsplit is whether the table being update is directly in the database or linked.

    You need to
    1) establish a field in each table that needs tracked.
    2) identify the user who is using the database.
    3) update the field in the table with the user ID.

    No difference in the code or macro.

  5. #5
    zdjbel is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    42

    Add a date when a change is made to an option group on a subform

    Quote Originally Posted by Dal Jeanis View Post
    I don't believe there is a difference between the method you'd use to log the user on a split versus a combined database. The only difference between split and unsplit is whether the table being update is directly in the database or linked.

    You need to
    1) establish a field in each table that needs tracked.
    2) identify the user who is using the database.
    3) update the field in the table with the user ID.

    No difference in the code or macro.

    Hi Dal! Thanks very much for the guidance, it I'll try to work this out and let you know how it came out.

    Cheers!

  6. #6
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Great! If you got what you need, please mark the thread solved. Top of page, under thread tools.

    Feel free to open a new thread with any new questions that come up.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Use of option group buttons
    By sireesha in forum Forms
    Replies: 1
    Last Post: 10-25-2012, 01:20 PM
  2. Option Group
    By x__hoE__x in forum Access
    Replies: 2
    Last Post: 12-10-2011, 09:39 AM
  3. Option group and date
    By kigor in forum Forms
    Replies: 0
    Last Post: 04-22-2011, 12:52 AM
  4. Option Group
    By huskies in forum Forms
    Replies: 9
    Last Post: 12-02-2009, 12:06 PM
  5. Option Group broken out
    By dcecil in forum Reports
    Replies: 3
    Last Post: 04-21-2009, 10:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums