Emergency!! passing value from form to calling form

Assume I have 2 forms of name parent and child.

Now I am originally in parent and open chld.  Now how do I pass or get values from this child to the parent.  The problem is that I want the child to be able to get the focus until the "OK" button is hit and the parent to receive the values only after the "OK" button on the child is hit and then get back the focus.  If anyone can help I will be greatly appreciative.  Thanks
cuchenduAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AnswerTheManCommented:
1.make sure both are Loaded (not neccerily visible).
2. declare all Variabels you want to pass *PUBLIC*, in declaration section of each form.
----------------------------
advanced :
you may leave them private if you use Get and Let property functions.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AnswerTheManCommented:
to call from Form1 to var in Form2 :

Dim L as Long
L=Form2.SomeLongPublicGlobalVariable

to set Form2 var from Form1 :

Dim L as Long
L=2000
Form2.SomeLongPublicGlobalVariable=L

0
Erick37Commented:
'~~~~~Parent form~~~~~~~
Option Explicit

Public sString As String

Private Sub Command1_Click()
    frmChild.Show 1, Me 'Open the Child form as modal
    Caption = sString
End Sub

'~~~~~~Child Form~~~~~~~
Option Explicit

Private Sub Command1_Click()
    frmParent.sString = "Child wrote this"
    Unload Me
End Sub
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.