Auditing a subform

M

mkj

Hello,

Having found some instructions for auditing changes to forms on the
internet, I have created an AuditTrail() method in a module, and have set all
my forms and subforms to call this method with the BeforeUpdate event.

Unfortunately, it appears that changes made in subforms aren't being
triggered. Though, if the subform is the only section on the screen with
changes, it still triggers the BeforeUpdate event on the main form.

Is it possible to get the main form to trigger the BeforeUpdate method on
subforms? This seems like the easiest option to me...

Cheers,

Mike
 
M

mkj

Hello,

This is the link to the page I have been using so far:
http://support.microsoft.com/default.aspx/kb/197592

I did see your page but as I'm not supposed to be spending too long on this
project, I was hoping that I could do something that didn't need extra tables
for every existing table I've already got. At the moment I have one
audittable with two memo fields. All controls in the main forms that have
changed details get their original values and current values copied into
these memo fields as (fieldname - value, fieldname - value,) etc. One memo
field is the original data, the other is for current data. If it's possible
to get your instructions to produce this, that would be all I need.

Any suggestions would be appreciated.

Cheers,

Mike
 
A

Allen Browne

Try modifying the routine so that you pass the form you are wanting to
audit, i.e.:
Function AuditTrail(MyForm As Form)
On Error GoTo Err_Handler
Dim C As Control, xName As String
and drop the line:
Set MyForm = Screen.ActiveForm

Then at step 7, use:
=AuditTrail([Form])
(Don't change the Form: it's exactly like that.)

That should work with subforms, nested to any depth.

You are probably aware that this routine does not audit deletions.
 
M

mkj

Actually, based on my last post, I'm looking at recursively running the
current method on each subform, by passing in the Form object. Is this
possible because every time it runs and tries to pass in the subform object,
the Function says "type mismatch". My function looks like

Function AuditTrailFromForm(theForm As Form)

This is the one that is repeatedly called. It looks fine to me, but I must
admint I'm looking at VB from a Java/C# background. Perhaps I just can't pass
a Form into a function (though sending it through as an object works, so
perhaps someone could show me how to convert an object back to a form from
within the function).

Hope that's clear enough...

Mike
 
M

mkj

Thanks - I'll try that - you can probably ignore my other post - I sent that
before I saw your last comment - thanks very much for your time so far!

Mike

Allen Browne said:
Try modifying the routine so that you pass the form you are wanting to
audit, i.e.:
Function AuditTrail(MyForm As Form)
On Error GoTo Err_Handler
Dim C As Control, xName As String
and drop the line:
Set MyForm = Screen.ActiveForm

Then at step 7, use:
=AuditTrail([Form])
(Don't change the Form: it's exactly like that.)

That should work with subforms, nested to any depth.

You are probably aware that this routine does not audit deletions.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

mkj said:
Hello,

This is the link to the page I have been using so far:
http://support.microsoft.com/default.aspx/kb/197592

I did see your page but as I'm not supposed to be spending too long on
this
project, I was hoping that I could do something that didn't need extra
tables
for every existing table I've already got. At the moment I have one
audittable with two memo fields. All controls in the main forms that have
changed details get their original values and current values copied into
these memo fields as (fieldname - value, fieldname - value,) etc. One memo
field is the original data, the other is for current data. If it's
possible
to get your instructions to produce this, that would be all I need.

Any suggestions would be appreciated.

Cheers,

Mike

"Allen Browne" wrote
 
M

mkj

Yes that worked! That's all I need from it at the moment. When I have more
time I'll have to look into doing it properly.

Thanks very much for your assistance!

Mike

Allen Browne said:
Try modifying the routine so that you pass the form you are wanting to
audit, i.e.:
Function AuditTrail(MyForm As Form)
On Error GoTo Err_Handler
Dim C As Control, xName As String
and drop the line:
Set MyForm = Screen.ActiveForm

Then at step 7, use:
=AuditTrail([Form])
(Don't change the Form: it's exactly like that.)

That should work with subforms, nested to any depth.

You are probably aware that this routine does not audit deletions.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

mkj said:
Hello,

This is the link to the page I have been using so far:
http://support.microsoft.com/default.aspx/kb/197592

I did see your page but as I'm not supposed to be spending too long on
this
project, I was hoping that I could do something that didn't need extra
tables
for every existing table I've already got. At the moment I have one
audittable with two memo fields. All controls in the main forms that have
changed details get their original values and current values copied into
these memo fields as (fieldname - value, fieldname - value,) etc. One memo
field is the original data, the other is for current data. If it's
possible
to get your instructions to produce this, that would be all I need.

Any suggestions would be appreciated.

Cheers,

Mike

"Allen Browne" wrote
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top