Loop through Forms Controls excluding SubForm

DrXia92

New member
Local time
Yesterday, 19:25
Joined
Jan 2, 2020
Messages
3
Hi everyone,

Happy to write my first post in the forum (after introduction) :)

I have an audit trail macro that loops through controls in a form and writes a change log table (I borrowed the code from techrepublic) However, while the macro works perfectly with forms without subforms I get type mismatch error in the only form that includes 2 subforms. I believe that if I am able to stop the macro from looping through the subform controls the error could go away.

At the moment the code is the following

Code:
For Each ctl In frm.Controls [...]

Is there a way to change this to be For each control in form excluding subforms?

Btw, the macro is called in the following way

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

Call AuditTrail(Me, Me.launch)

End Sub


Thanks!
 
Thank you both for the quick replies! I did not realize that subforms had their own control type :D This helped me realize the issue was not with the subform but with one Combo Box control that had multiple values allowed.

Thank you again!
 

Users who are viewing this thread

Back
Top Bottom