Hi all,
I'm not sure if this is possible, but I want to return an object from a user-defined OCX control. Can anyone help me with this?
Background info:
I created an OCX control the receives 2 objects (form and control) and a string. I would like this OCX control to return the form instance when it's processing has been completed.
Code:
OCX initiation from calling program ...
Private Sub Form_Load()
Dim objReturn As Object
Set objReturn = AlltelLogon1.LogonToAlltel(frmDisplay, frmDisplay.Display1, strAppName) 'User-defined OCX control
If objReturn Is Nothing Then
End
Else
Unload Me
objReturn.Show
End If
End Sub
OCX code ...
Function LogonToAlltel(DisplayForm As Object, MainFrameDisplay As Object, _
ApplicationName As String) As Object
'* Controls public object variables
Set FScrn = DisplayForm
Set MScrn = MainFrameDisplay
strAppName = ApplicationName
intLoginTries = 1
AttemptLogon '* Processing functions
'* Return nothing if login fails, else return form instance
If Stat <> 0 Then
Set LogonToAlltel = FScrn
Else
Set LogonToAlltel = Nothing
End If
End Function
Problem:
I get an "Object required" error in the calling program when I use this method. If I change the OCX function to return as long, then the form instance is unloaded after the login has been completed successfully.
Any ideas? Your help will be greatly appreciated.
Thanks in advance.
ERM
I'm not sure if this is possible, but I want to return an object from a user-defined OCX control. Can anyone help me with this?
Background info:
I created an OCX control the receives 2 objects (form and control) and a string. I would like this OCX control to return the form instance when it's processing has been completed.
Code:
OCX initiation from calling program ...
Private Sub Form_Load()
Dim objReturn As Object
Set objReturn = AlltelLogon1.LogonToAlltel(frmDisplay, frmDisplay.Display1, strAppName) 'User-defined OCX control
If objReturn Is Nothing Then
End
Else
Unload Me
objReturn.Show
End If
End Sub
OCX code ...
Function LogonToAlltel(DisplayForm As Object, MainFrameDisplay As Object, _
ApplicationName As String) As Object
'* Controls public object variables
Set FScrn = DisplayForm
Set MScrn = MainFrameDisplay
strAppName = ApplicationName
intLoginTries = 1
AttemptLogon '* Processing functions
'* Return nothing if login fails, else return form instance
If Stat <> 0 Then
Set LogonToAlltel = FScrn
Else
Set LogonToAlltel = Nothing
End If
End Function
Problem:
I get an "Object required" error in the calling program when I use this method. If I change the OCX function to return as long, then the form instance is unloaded after the login has been completed successfully.
Any ideas? Your help will be greatly appreciated.
Thanks in advance.
ERM