I have a form with a subform. I have a field in the subform datareprogramada. The user can delete this and insert a new date. All I need to do a history of these dates. I tried to do a sub into the sub, but could not. Does anyone have any tips?
I have a form with a subform. I have a field in the subform datareprogramada. The user can delete this and insert a new date. All I need to do a history of these dates. I tried to do a sub into the sub, but could not. Does anyone have any tips?
In addition to info in your other thread, see http://access.mvps.org/access/modules/mdl0021.htm
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.
June, The first thing I downloaded contain errors. I tried to get the idea but could not. The last you sent the access was 97 when I did the conversion to access 2007, appeared a lot of error. Do you have another model, or some site where I can search?
Those were result of Google search. Here is one more and that exhausts my search effort http://allenbrowne.com/appaudit.html
Allen Browne normally has good product.
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.
June, just a guideline.
sKeyField = name of the AutoNumber field. (ok I put the name)
lngKeyValue = Value of the AutoNumber field .(???????????). What value should I enter?
lngKeyValue is one of the variables declared in the function declaration:
Function AuditDelBegin(sTable As String, sAudTmpTable As String, sKeyField As String, lngKeyValue As Long) As Boolean
These variables are function arguments. You must pass values to the function when the function is called. You call the function is some event procedure, like:
x = AuditDelBegin("your table name", "audit table name", "name of the field", Nz(Me.KeyFieldname,0))
Values between the quotes will be literal strings, not variables. The lngKeyValue is captured by referencing the field on the form. This is a variable.
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.
Just to confirm:
Function AuditEditBegin(sTable As String, sAudTmpTable As String, sKeyField As String, _
lngKeyValue As Long, bWasNewRecord As Boolean) As Boolean
Function AuditEditBegin(TblPassosStatus As String, audTblPassosStatus As String, CodPassosStatus As String, _
Nz (Me.CodPassosStatus, 0))As Long, bWasNewRecord As Boolean) As Boolean
No. Do not change the function declaration. You pass data to the function arguments by calling the function.
You should do some self-educating on how to build and use custom 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.
June,
I made a different database, (attached) just to test the model of Allen.
I did exactly as he describes, including table names and key.
But there was a runtime error.
Is it because of my version of Access?
It errors when trying to run the LogError function. Run Debug>Compile and the compiler will error on the LogError function call. Always Debug>Compile after VBA edits. Refer to link at bottom of my post for tutorial on debugging techniques. Allen Browne states in his article:
3. Either remove the four references to function LogError(), or set up error logging as described in Error Handling.
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.
That's what I did. I removed the four references to LogError function (). If the db I sent you was with the references, it is because I did a test with the references
You are using tblInvoice as the table name in the function calls. There is no table with this name. Change to sTable.
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.
June7,
In my bank test worked perfectly. I see now how is the officer.
The fact that I have put all the instructions on how to goto err comments will have any difference in performance?
I would put a column in my subform count the number of times that the rescheduled date was changed. As this counter increment every change of date rescheduled?
In the event rescheduled date after upgrading, I was thinking something like:
A while statement
Me.contador= Me.contador + 1
How do the syntax. The counter must start with zero, because the first record of the rescheduled date is not an issue.
Thank you.
Lack of error handler means any error that could crash or lock up the code excecution is not managed. Otherwise, not performance issue.
Why count times changed? Counter code not practical. Where would you save this number for future reference? This number could be calculated by query on the audit table. In the event that commits record to audit table, use DCount function to count the records in audit table with the target record's ID and set textbox to this value, something like:
Me.textboxname = DLookup("fieldname", "tablename", "ID=" & Me.ID)
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.
Forgive my ignorance. What error that can occur and code execution fails?
The error handler function is to tell where the error?
confirming:
I want to create a field in my subform to the counter, do not want a text box.
In the after update event of the rescheduled date field put:
Me.Counter = DCount ("Field Name", "tablename", "ID =" & Me.ID)
Is that it?