Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 53
  1. #31
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    As I mentioned in post #6, the code is designed for a MainForm only. I just did a test and this line: Set MyForm = Screen.ActiveForm points to the MainForm regardless of you calling it from the SubForm or the MainForm.

  2. #32
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Thanks RG...I did make a modification to the code in #12 to allow the code to work on the subform as well.

    Code:
    Function AuditTrail(MyForm As Form)
    On Error GoTo Err_Handler
        
        Dim C As Control, xName As String
        'Set MyForm = Screen.ActiveForm
        'Set date and current user if form has been updated.
        MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
        "Changes made on " & Now() & " by " & Environ("USERNAME") & ";"
    In searching other posts on this subject, the particular line of code you identified was the problem getting the code to work with subforms so it was REM'd out.

  3. #33
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Sorry, I lost track of the changes. You are correct about post #12. Darn, I hate it when that happens!

  4. #34
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    No problem RG...this post has gotten too big and difficult to follow. I would like to close it out but it really isn't completely solved. Thanks for taking the time to look at it.

  5. #35
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Keep the thread open until we pin down what is going on. We'll get there.

  6. #36
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would like to see a test that enumerates the controls of a SubForm. I'm not so sure you can access the Control collection of the SubForm this way in your For...Next loop. The SubForm is *not* in the FORMS collection and may therefore need to be accessed through the MainForm.SubForm type of syntax. I'll try and put together that testbed and see what happens.

  7. #37
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    OK...that test proved me wrong. It does enumerate the correct control collection. Back to the books on this one.

  8. #38
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Right...I am having no problem with the controls being enumerated on both the sub and the main. Somehow, I need the code to be able to identify when it is finished with the subform controls and starting on the main form controls so it can print the Date/Time info to where the main form audit trail is stored.

  9. #39
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What event in both the MainForm and the SubForm do you use to invoke this procedure?

  10. #40
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Before Update

  11. #41
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That is the Form_BeforeUpdate event of the MainForm and the SubForm right? Do you know how Access fires those events? If you have made changes to the MainForm that Dirties the MainForm RecordSource then Access will save that record when you move the focus from the MainForm to the SubForm or if you try and leave the MainForm record for any other reason as well (Exit, Close the form, NextRecord...). The same thing happens when you move the focus in the SubForm. If your SubForm is in Continuous Form view then moving to the next record will save if the record is Dirty. Also moving the focus back to the MainForm will save if the Current record is Dirty. Is that your understanding of the process?

  12. #42
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Yes, it is the Form_BeforeUpdate for both main and subform. And yes, that is my understanding. I follow.

  13. #43
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So I re-read your post #29 for the 50th time and a light is starting to glow. Are you saying that you want the AuditTrail to record the fact that the user made a change to the SubForm in the MainForm AuditTrail control, even though no change was made in the mainForm record?

  14. #44
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did I lose you there? Do I have it all wrong?

  15. #45
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Sorry, got sidetracked with work. If a user makes an edit to the subform (responses), I only need the audit trail to record in the tblQuestResponseSet. Do not need to make an audit trail in the Main form audit trail. That is working correctly. Conversely, if i make an edit on the main form (question) but no change on the subform, the audit trail should go to tblQuestions. This is also working correctly - I will see the change in the audit log on the tblQuestions and nothing on the tblQuestResponseSets. But, in this last scenario, the Date/Time part is missing on the main audit log. In the first scenario, the Date/Time prints on the subfrom audit trail (tblQuestResponseSets). In fact, in every test case I have run, each time the audit trail on the tblQuestResponseSets (subform) is correctly stamping the date/time.

Page 3 of 4 FirstFirst 1234 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. audit Log
    By mwabbe in forum Access
    Replies: 42
    Last Post: 05-30-2011, 07:23 AM
  2. Audit trail question #2
    By jpkeller55 in forum Access
    Replies: 9
    Last Post: 09-13-2010, 05:55 PM
  3. Audit trail question
    By jpkeller55 in forum Access
    Replies: 5
    Last Post: 09-13-2010, 04:12 PM
  4. Filter By Form not working!
    By Freybourne in forum Access
    Replies: 6
    Last Post: 06-22-2010, 09:41 PM
  5. Replies: 1
    Last Post: 09-28-2009, 05:21 PM

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