Discussion Locked

passing data from ActiveX ctl to forms

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

i have an ActiveX control wherein various forms are also used. Inside the control there are various events which when fired call the FORMS. Users interact with these forms, and once completed and submitted they are to be displayed inside the main Control.

Now my problem is in displaying the form values in the Control. How do I do it.

Pls. help

Regards

Amit Bhargava

5 replies

by bggangel

Let me see, if I understand you correctly, and if I do, maybe I can help you.
1. You have an ActiveX control that contains forms.
2. You use events to call these forms (.Show Modal).
3. When the form is closed, you want to return some of the values from the form to the control.

If this the case you can do several things.
I'll explain an easy one. (the otherone is thru a property Get, passing the ActiveX control to the form)

Call the form eg. frmMain.Show vbModal as you probably do now.
When closing the form DO NOT unload the form, but Hide it. (frmMain.Hide)
When you hide the form, it stays in the memory. You can now still read the controls from your form and put them in the variables of your ActiveX control.
When your done, you can unload the form.(unload frmMain)

by drdownen

Try This as an example. I copyed some code so you will have to change it. UserControl(ActiveX) add a Form called frmFilterTime in this example. TextBox on the Form. Put this code in the UserControl.

Option Explicit

Private WithEvents mFilterTimeForm As frmFilterTime
Private mVariable as String

Private Sub mFilterTimeForm_FormClosed()

Const cProcName As String = "mFilterTimeForm_FormClosed"
On Error GoTo ErrorTrap

'YOUR CODE Here to transfer the information. Like
mVariable = mFilterTimeForm.TextBox.Text

ErrorTrap:
App.LogEvent cControlName & "." & cProcName & " - Error # " & _
Err.Number & " - " & Err.Description, vbLogEventTypeError

End Sub

This discussion is closed to new replies.