Hi Tommy.
>>The most general solution is to pass FormA to FormB, eg. Thisform.oFormB=createobject("FormB",Thisform). Now both forms know of each other and can work together.
The easiest way to accomplish the general case of FormA calling FormB to perform some task and returning a value back to FormA is:
- Make FormB modal or call its Show method as Show(1) so it runs as a modal form.
- There's no need to store a reference to FormB in a FormA property; since FormB is called modally, the FormA method calling FormB doesn't terminate until FormB closes, so using a variable to hold the reference is fine.
- In FormB, have an OK button with code like this in its Click method:
Thisform.SomeProperty = TheReturnValue
Thisform.Hide()
Have a Cancel button with Thisform.Release() in its Click method. If the user clicks Cancel, FormB is released. If the user clicks OK, FormB is hidden and control returns to FormA, which can then check FormB.SomeProperty for the return value. Example code in FormA:
loForm = createobject('FormB')
loForm.Show(1)
if vartype(loForm) = 'O'
lcReturn = loForm.SomeProperty
else
endif
Doug