Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 36
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    What error? Don't know, this can often be something totally unexpected. The error handler can be set up to give you an error code but won't really tell you exactly what is causing the error. Error handler is supposed to deal with any possible error and prevent the program from a crash that locks the program and user can't exit or even freezes the entire computer. Do you really need error handler? Depends on your program.



    You want to save the count of records - why? This is a dynamic value and can be calculated whenever needed. But if you must, yes, create a new field in the table and then in event populate it with the expression.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    June7,
    Thank you for your explanation.
    Like I said in a previous post, I want to create a count of the number of changes in a field. For example, in my subform fields where I step, scheduled, rescheduled date, date performed, and counter. I want the counter shows the number of times that the rescheduled date field has changed in a certain step.
    I would like you to tell me if the function is correct that I did call this function and how to fill the field counter.

    Function DatareprogramadaCount(Datareprogramada As String, audInvoice As String, InvoiceID As Long) As Integer
    DatareprogramadaCount = DCount(“[Datareprogramada]”, “audInvoice”, “[InvoiceID]”)
    End Function

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Your DCount is incomplete. The last argument is a WhereCondition and requries an expression.

    Inside the custom function would be (assumes the function is behind the form):
    Me!DatareprogramadaCount = DCount("[Datareprogramada]", "audInvoice", "[InvoiceID]=" & InvoiceID)

    However, there is no reason to put this inside a custom function. Put the DCount in place of the call of custom function.
    Me!DatareprogramadaCount = DCount("[Datareprogramada]", "audInvoice", "[InvoiceID]=" & Me!InvoiceID)

    I must repeat that actually saving this value to table is not necessary. The DCount function can be used in queries and in textboxes whenever needed to generate this value. Can also do aggregate query with Count function.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #19
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    It worked, but as the audit table records the edited, published for, deleted, inserted.
    When inserting a new record in the rescheduled date, the counter shows 0. (perfect, it is used only to count change). When I change the date rescheduled, the counter shows a (perfect). When I change the date rescheduled again, the counter shows 3 (2 would be right), then 5.7 ...
    Do you think you have to do Ifs and elses?

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    The DCount should be a count all records in the audit table for the ID, not the number of times changed (a difference of 1 between these two). Don't know why the first one shows 0, should show 1. Ifs and Elses will not help.

    I would have to examine your project again.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #21
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    Yes, the DCount account all audit records in the table for identification. But I'm trying to counter the subform only shows the amount of rescheduled date field changes.
    I did in my database, exactly what I did on the bench test (which worked), but generated an error. You can tell me where did I go wrong?

  7. #22
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    June7, removed the count field of the table and also PassosStatus the subform, and apparently the audit table is running fine (the file I sent you in the event of the subform, put TblAuxiliarPassosStatus wrong. Corrected to the correct title TblPassosStatus).
    I wonder why not run counter to the field. In the event after updating the rescheduled date field, put the code you told me the same code module of the other events. Was it that caused this error code?

  8. #23
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    The audit history procedure is not working for me. Errors in the AuditEditBegin procedure when I edit existing record on the db.Execute line. This made me see that the SQL construct just above that has an error. The NetworkUserName() function needs to be concatenated, not included within the quotes.

    However, even after fixing that, the db.Execute still errors. I will let you debug further.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #24
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    June7, apparently managed to solve. I had forgotten to put the count field in the audit and audit temporary tables. I apologize.
    In the event of the subform left only after the event update. Thus the counter works perfectly. It is the history of each amendment that was my initial goal.
    I'm trying to create a text box on the form, for when selecting certain step, show the change history of this specific step. Can you give me a hint in the VBA code that I have to use?

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Sorry, that attachment won't download. I get message it is corrupted.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #26
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    how do I fix

  12. #27
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Try zipping it again and replace the attachment in that thread or attach to another thread. Are you using Windows compression? Only zip type I can open.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #28
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    I'm sending back the file. Download the file from the site and had no problems.
    I'm doing the same way they always sent the files.
    What do you mean by compression Windows?

  14. #29
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    I don't know Windows 7 but in Windows XP, in Windows Explorer, to create zip folder, right click > New > Compressed (zipped) Folder. Drag and drop files into the zip folder.

    This time file did download.

    The code all seems to be working. Now think I understand why the count saved is one less than the actual number of records. It is because the count is calculated before the audit record is actually committed to the table. If this is what you want, then think your efforts are successful. Congratulations!
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #30
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    Thank June7.
    As for the text box on the form, for when selecting certain step, display the change history of this particular step, you want me to open a new topic?

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

Similar Threads

  1. Historical data
    By Accessgrasshopper in forum Access
    Replies: 0
    Last Post: 02-28-2011, 06:39 PM
  2. Replies: 3
    Last Post: 02-04-2011, 07:32 AM
  3. Replies: 1
    Last Post: 12-09-2010, 08:29 AM
  4. Mixed dates - show only complete dates?
    By weeblesue in forum Queries
    Replies: 3
    Last Post: 10-27-2010, 02:15 PM
  5. Query using historical table
    By kwilliams5675 in forum Queries
    Replies: 1
    Last Post: 10-05-2010, 03:23 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