Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have learned more through this forum than I did on a two day course. Thanks to everyone for their help and other postings that I have found useful..."

Geography

Where in the world do Tek-Tips members come from?

How to run a form event from another form.

davidb88 (TechnicalUser)
3 May 12 4:56
Hello,

I am using some product data management software that was written in VF6. The software allows me to add and run UDF code and form event code and I have managed to add some nice additional functionality.

The software is based around two forms, and some of the fields on form1 relate to calculated fields on form2.

I have a form event (instead of save) code on form2 which I want to trigger when saving form1, thus updating the calculated fields on form2. Form 1 and 2 are always active and I have tried using form2.save from form1, but it does not work.

Oddly, I have managed to call the 'after refresh' event on form2 from form1 using form2.refresh.

Any help would be appreciated.

Thanks,

David
OlafDoschke (Programmer)
3 May 12 5:18
What is form1.parentclass? Empty?

If not, and if you write code into form1.save() to call whatever
method of form2, then call DODEFAULT() before that within form1.save() to execute the predefiend save code.

Otherwise you override the save and don't save, thus also form2 will not refresh. That would explain it.

Bye, Olaf.
davidb88 (TechnicalUser)
3 May 12 5:47
Hi Olaf and thanks for your reply

I think the parent class is empty.

Sorry, I am a bit of a novice...

Should the code be constructed like this?

CALL DODEFAULT(form2.save())

Thanks, David

 
OlafDoschke (Programmer)
3 May 12 11:01
If the parentclass property is empty there is no need to call DODEFAULT(). The nomenclature is different, doesn't matter.

I'm sorry, I'd need to know more about the concept of the application and adding UDFs to it. Are you working with VFP itself or does the application provide an interface to add code?

Do you have any kind of documentation about this extensibility feature you could share?

Bye, Olaf.

 
SBTBILL (Programmer)
14 May 12 14:25
I do calls to other forms all the time basically you send form_name.procedure. However, you say you want to do calculations. Why use another form instead of a user defined method. That would normally be called with thisform.method. That should be faster.

If I have standard calculations I'd normally call them in a Prg with you go to with do prg with x,y,z

Call would normally be a VB command to me. While VFP and VB have extremely similar syntax it isn't identical.
foxmuldr (Programmer)
17 May 12 9:22
An easy solution is to create an object which hangs on _screen, which holds the form objects as passed parameters.

_screen.addObject("_myHolder", "myholder")
* Do whatever to launch forms 1 and 2, and in their init code, use this:

*FormN.init()
_screen._myHolder.formN_checkin(1, thisForm)
_screen._myHolder.formN_checkin(2, thisForm)

And then you can always reference either one from either form by using:
LOCAL loForm
loForm = _screen._myHolder.get_formN(1)
IF !ISNULL(loForm)
loForm.whatever
ENDIF

...

DEFINE myHolder AS Custom
form1_object = .NULL.
form2_object = .NULL.

PROCEDURE formN_checkin
LPARAMETERS tnForm, toForm
DO CASE
CASE tnForm = 1
form1_object = toForm
CASE tnForm = 2
form2_object = toForm
* more references could be added here
ENDCASE

PROCEDURE get_formN
LPARAMETERS tnForm
DO CASE
CASE tnForm = 1
RETURN form1_object
CASE tnForm = 2
RETURN form2_object
* more references could be added here
ENDCASE
RETURN .NULL.
ENDDEFINE



Best regards,
Rick C. Hodgin

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close