Audit Trail (3 Viewers)

dajabo said:
Er, excuse my stupidity, :eek: but I don't know how to get AuditTrail to work in my DB!

I have imported the module dAuditTrail, but how what do I do now?

I haven't a clue!!
You have to call the Audit_Trail() Function in your forms BeforeUpdate event. Like this...

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Err
    
    Call Audit_Trail
    
Form_BeforeUpdate_Exit:
    Exit Sub
    
Form_BeforeUpdate_Err:
    MsgBox Err.Number & " - " & Err.Description
    Resume Form_BeforeUpdate_Exit
    
End Sub
Go back to my original sample and look at the code for the fEmployees form. Open all of the db objects up and dissect it, explore it and have some fun.
 
yes I worked it out eventually, thankyou, and for the script which is brilliant!!

Can anyone suggest why I am now getting:

error:2472 - you have entered an expression which has no value

everytime I modify a field??

I assume it refers to an expression in dAuditTrail as nothing else has changed. But scanning the code I can't find anything redundant. It only occurs whenever I modify a field's contents, and when I go to move to another record, which also suggests it is AuditTrail as I don't have any other form-wide events.
 
Unbound Fields

In my attempt at using the Audit Field on my Access form, I am using unbound fields rather than bound fields. GHudson's sample DB seems to be using bound fields. Since I have tried everything but my Audit Trail DB based on GHudson's is not working so I am wondering if it is because of the unbound fields???

Any help would be greatly appreciated.

Thanks in advance.

Brett
 
First off thanks for this audit trail ghudson. Next, I admit, that my knowledge of VBA is limited. I worked for a while last night trying to get this bit of code to write to a seperate table instead of the one that it is. Is that possible? If it is can someone point me in the right direction?

Thanks,
Matthew
 
ghudson said:
Here is the new and improved version of my Audit Trail sample. Please post back if you have any suggestions. Thanks!

Is there a way to apply this functionality to a subform (while using it at the main form level, using the same module) as well? (Since Screen.Active form calls the main form.)
 
Just wondering

As I can see a lot of people are asking here for an audit trail version that allow the tracking of changes made on a subform. I would like to have this, too. Ghudson was so kinde to put his sample database to public view, but other people who managed the change of his code to work on subform aren't that kinde. I ask myself and I'm wondering, why? Not everybody has the knowlege and ability to do it by him(her)selfe, so why don't you help us?
Thanks.
Attila
 
2 hours of my life I'll never get back, please help.
I have AuditTrail implemented perfectly in my database. Works like a champ for one of my forms.
I believe I've replicated the exact same setup on another form (i.e. AuditTrail field named tbAuditTrail, BeforeUpdate event on the form, etc) yet I get a "438 - Object doesn't support this property or method" any time I try to save or exit the record. I've commented out the BeforeUpdate event and the error disappears, so I know it's an issue with the audit trail.
Please help!!
 
Audit Trail Error

JordanR - did you work out what was causing your error?

I will add my praise for the audit trail demo, it works wonderfully. On all except one of my forms the audit trail works without errors. On my main input form, everytime I update a combobox I get the error 3251 - Operation is not supported for this type of object. Even though it saves the changes in the table. Has anyone come across this issue on their audit trail journey? I have 2 sub forms within this main form and I have no issues with these - then again they have no comboboxes.
Cheers.
 
For those who are interested, I commented out the following error handling lines and the audit trail now works as it should.

If Err.Number = 64535 Then 'Operation is not supported for this type of object.
Exit Function
ElseIf Err.Number = 2475 Then 'You entered an expression that requires a form to be the active window
Beep
MsgBox "A form is required to be the active window!", vbCritical, "Invalid Active Window"
Else
BeepMsgBox Err.Number & " - " & Err.Description
End If

Cheers,
 
I highly suggest that you uncomment the error trapping you altered and add the appropriate error trap for the new error # 3251 you are getting in your application. Like this...
Code:
If Err.Number = 64535 Then 'Operation is not supported for this type of object.
     Exit Function
ElseIf Err.Number = 3251 Then 'Operation is not supported for this type of object. 
     Exit Function
ElseIf Err.Number = 2475 Then 'You entered an expression that requires a form to be the active window
     Beep
     MsgBox "A form is required to be the active window!", vbCritical, "Invalid Active Window"
Else
     BeepMsgBox Err.Number & " - " & Err.Description
End If
There is a reason we use error trapping with our applications. You should always trap for the unexpected as well as the expected [known] runtime error's your application might have and handle those in a way that will enhance the users experience with your application.
 
I wasn't aware I could just add this error in, thanks for that ghudson I will put it all back.
Cheers.
 
Hi

I have started encountering a problem whereby I get the following error message when the Audit Trail tries to run,

Could not update; currently locked by another session on this machine

I have looked at Google and have noticed that other people seemed to encounter this error when there Memo fields went above a certain size. My largest memo field appears to be only 3,811 characters long and supposedly Access can handle 64,000.

Does anyone know how to solve this?

Thanks.
 
Alright, I solved it by creating a recordsetclone in the form_current and then creating a function getControlValue in the form class that would take the name of the control and return the value from the recordsetclone (this only worked if the controls had the same names as the fields in the tables). Then value = MyForm.getControlValue(ctl.name). Finally, I replaced all the ctl.oldvalue with value. Plus some other minor edits.
 
Excellent solution GHudson. I'm adding this to my database. I have one problem with the combo box.

By default it saves information from column(0) which is a number and does not have any meaning to the user. How do I get it to save information from column(1)?

Thanks for any help, Rob
 
Are you asking me for help or is your name Rob too. Anyway, if you are I've just started using access a month ago and haven't even looked at combo boxes yet but couldn't you just do something in the getControlValue function like

if (name of control passed to function = name of combobox) then
return value of column(1) from recordsetclone
else
return recordsetclone.fields(name of control passed to function).value
 
My name is also Rob. The question is for anyone who has suggestions on how to solve this problem.

Rob
 
GHudson, I have to agree great job on Audit Trails.
Lyn?

I had the same problems with other versions of AuditTrails and subforms, I'll take your changes into account also.

Thanks.
 
Audit Trails..

GHudson, I have to agree great job on AuditTrails. I spent good part of 3 days trying to get other versions to work properly.

Also, to Lyn I had same problem with a form having a subform so I'll take your changes into occount.

Thanks..:) :)
 

Users who are viewing this thread

Back
Top Bottom