Pass the current form name to a function within a module


I am trying to send the current form name to a function when the OnCurrent event occurs. I am currently using the following code which is producing an error:

On Current

and in my vba module...

Function LoadArray(FormName As Form)
    Set CurrentForm = FormName
End Function

The error I am getting is "The object doesn't contain the automation object 'Me.'"

Where am I going wrong? Thanks in advance

Who is Participating?
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
in the On Current event of the form remove  =LoadArray(Me)
select Event Procedure from the drop down
then click on the (...)
place this in the VBA window

Private Sub Form_Current()
Call LoadArray(Me)
End Sub

Rey Obrero (Capricorn1)Commented:
remove the [ ]

On Current

On Current

All you want is the form NAME passed?
If so, just use:


Function X(fn As String)
mattryanjerseyAuthor Commented:
Thanks for your ideas, unfortunately all of the above create the same error message. I cannot seem to remove the square brackets. When I type, for example =LoadArray(Me) and then leave the input box they are added back in automatically. I'm using access 97 by the way.
All Courses

From novice to tech pro — start learning today.