Inexperienced user here.
I have multiple forms within my database in which I copy the value of one control to another, some of them are ComboBox controls for which I use the value from a particular column. Currently I use a separate button and VBA sub for each instance, which works fine.
I have been trying to simplify this with a single global function that I can call with a macro to accomplish this task, but I seem to be unable to access the control.Column(x) value when using this method.
My global function looks like this (I use a function as it seems I cannot call a sub from a macro):
Code:
Function copy_value(FromControl, ToControl As Control, Optional col As Long = 0)
If col = 0 Then
ToControl.Value = FromControl.Value
Else
ToControl.Value = FromControl.Column(col).Value
End If
End Function
Works fine for controls without the Column property, but fails with error 424 otherwise.
Is there a way to make this work, or a better way to achieve this?