I would like to have a general utils module, consisting of several methods that will generically work on any form passed to it. These modules will be called on by form event handlers.
My first attempt was to pass the form in as a parameter. This would be my most preferred method if I could get it to work. The module method signature looked like:
Public Sub LoadRecord(ByVal form As Form)
and the event handler simply consisted of one line:
DBUtils.LoadRecord(me) or DBUtils.LoadRecord(Form)
When I ran the code, I got a type mismatch error.
So then my second method was to pass in the form name to the module, and have the module look it up. So the module looked like:
Public Sub LoadRecord(ByVal form As String)
Dim myForm As Form
myForm = Forms(formName)
However, the compiler issues "An invalid use of property" on the second line.
So now, I just use Forms(formName) inside LoadRecord whenever I need access to the form. This works, but it appears inefficient as it would performing a form lookup each time I need access to a form.
Any suggestions on how to get the first two examples working?
Thanks so much.