I have a form that runs a series of sub routines when it loads. In my subs, I want to use a variable which pulls the name of the current form that I'm loading. I have the following code, but I keep getting error 2475: "You entered and expression that requires a form to be the active window".
How am I supposed to define the form's name when the form loads, without getting error 2475? I've tried to run it on open rather than on load, but still doesn't work.
Code:
Private Sub Form_Load()
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
Dim frmName As String
frmName = frmCurrentForm.Name
'I have various script like the one below which I need to use the form name as a variable
userNameBC = Forms(frmName).userName.Value
End Sub
Comment