Loop through Forms Controls excluding SubForm (1 Viewer)

DrXia92

New member
Local time
Today, 16:28
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!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:28
Joined
Feb 19, 2013
Messages
16,553

DrXia92

New member
Local time
Today, 16:28
Joined
Jan 2, 2020
Messages
3
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

Top Bottom