Friends
In a new application I am developing, I have a Form with a Command button The Command button opens a 2nd form
When my client enters data into this 2nd form, I need to show what is being typed in a Text box on the 1st form. Can that be done?
Yes be the answer.
I'd probably attack it by passing a reference to the text box to be updated to the 2nd form. In the control on the 2nd form interactive change event have that set the caption of the text box on the first form to the value of the control on the 2nd form.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Sytze de Boer Sent: Wednesday, 6 July 2016 9:02 AM To: profoxtech@leafe.com Subject: updating 2 forms
Friends
In a new application I am developing, I have a Form with a Command button The Command button opens a 2nd form
When my client enters data into this 2nd form, I need to show what is being typed in a Text box on the 1st form. Can that be done?
-- Kind regards, Sytze de Boer
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
[excessive quoting removed by server]
Darren, thanks for your suggestion. But I'm stuck on how to pass such a reference Can you suggest?
On Wed, Jul 6, 2016 at 11:12 AM, Darren foxdev@ozemail.com.au wrote:
Yes be the answer.
I'd probably attack it by passing a reference to the text box to be updated to the 2nd form. In the control on the 2nd form interactive change event have that set the caption of the text box on the first form to the value of the control on the 2nd form.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Sytze de Boer Sent: Wednesday, 6 July 2016 9:02 AM To: profoxtech@leafe.com Subject: updating 2 forms
Friends
In a new application I am developing, I have a Form with a Command button The Command button opens a 2nd form
When my client enters data into this 2nd form, I need to show what is being typed in a Text box on the 1st form. Can that be done?
-- Kind regards, Sytze de Boer
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Various ways.
You could pass a parameter when you create the 2nd form and pick that up in the Init of the 2nd form then set a property on the form with the object reference.
You could create the form and then set a property on the 2nd form with the object reference (depends if from is modal or not).
You could use _Screen or some other public object to hold a property with the object reference.
You could create a variable scoped public and set that to the object reference.
I am sure there are more but that should give you something to work with.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Sytze de Boer Sent: Wednesday, 6 July 2016 9:45 AM To: profoxtech@leafe.com Subject: Re: updating 2 forms
Darren, thanks for your suggestion. But I'm stuck on how to pass such a reference Can you suggest?
On Wed, Jul 6, 2016 at 11:12 AM, Darren foxdev@ozemail.com.au wrote:
Yes be the answer.
I'd probably attack it by passing a reference to the text box to be updated to the 2nd form. In the control on the 2nd form interactive change event have that set the caption of the text box on the first form to the value of the control on the 2nd form.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Sytze de Boer Sent: Wednesday, 6 July 2016 9:02 AM To: profoxtech@leafe.com Subject: updating 2 forms
Friends
In a new application I am developing, I have a Form with a Command button The Command button opens a 2nd form
When my client enters data into this 2nd form, I need to show what is being typed in a Text box on the 1st form. Can that be done?
-- Kind regards, Sytze de Boer
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Plenty of ways to do it but I'd avoid global variables if you can help it.
If we knew more about the purpose/application, I think you could get additional advice.
Typically, I have a form that is a List/Library form. User clicks on the "Add" (record) button and I launch the 2nd (MODAL!) form like this:
cmdAdd.Click code: thisform.AddRecord()
* thisform.AddRecord code: DO FORM frmNewRecord NAME loFrm NOSHOW && this form uses an object called oRecord in the form, complete with the field names I need loFrm.cMode = "ADD" loFrm.Show() && user does his voodoo here and presses either the Save or Cancel button, setting the lSaveChanges form property if loFrm.lSaveChanges then liKey = this.obiz.AddRecord(loFrm.oRecord) && will add the record and return the PKey generated (if using autoinc integer keys) endif loFrm.release this.GetRecords() && requeries list/library select (this.grd.RecordSource) locate for iid = liKey this.grd.refresh()
On 2016-07-05 20:00, Darren wrote:
Various ways.
You could pass a parameter when you create the 2nd form and pick that up in the Init of the 2nd form then set a property on the form with the object reference.
You could create the form and then set a property on the 2nd form with the object reference (depends if from is modal or not).
You could use _Screen or some other public object to hold a property with the object reference.
You could create a variable scoped public and set that to the object reference.
I am sure there are more but that should give you something to work with.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Sytze de Boer Sent: Wednesday, 6 July 2016 9:45 AM To: profoxtech@leafe.com Subject: Re: updating 2 forms
Darren, thanks for your suggestion. But I'm stuck on how to pass such a reference Can you suggest?
On Wed, Jul 6, 2016 at 11:12 AM, Darren foxdev@ozemail.com.au wrote:
Yes be the answer.
I'd probably attack it by passing a reference to the text box to be updated to the 2nd form. In the control on the 2nd form interactive change event have that set the caption of the text box on the first form to the value of the control on the 2nd form.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Sytze de Boer Sent: Wednesday, 6 July 2016 9:02 AM To: profoxtech@leafe.com Subject: updating 2 forms
Friends
In a new application I am developing, I have a Form with a Command button The Command button opens a 2nd form
When my client enters data into this 2nd form, I need to show what is being typed in a Text box on the 1st form. Can that be done?
-- Kind regards, Sytze de Boer
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Maybe something like this :-
do form Form1 name FIRSTFORM
This form has text1 object
When you run the second form
As you enter the text in the textbox object, in the interactivechange method :-
FIRSTFORM.text1.value = this.value FIRSTFORM.text1.refresh
Is that what you are thinking of ?
On Wed, 6 Jul 2016, at 12:02 AM, Sytze de Boer wrote:
Friends
In a new application I am developing, I have a Form with a Command button The Command button opens a 2nd form
When my client enters data into this 2nd form, I need to show what is being typed in a Text box on the 1st form. Can that be done?
-- Kind regards, Sytze de Boer
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
This is a good example of why you should use form classes.
Have your parent form class 'frmParentForm' and have a method called SetTextBox() on it which takes a string. Also have your button to launch your child form.
SetTextbox() code:
lparameters lcString thisform.textbox1.value = lcString
Your child form class 'frmChildForm' has a property 'CallingForm' and a method called Setup()
So in your code:
loParentForm = CreateObject("frmParentForm") loParentForm.Show()
In your parent form 'launch child form' button:
loChildForm = CreateObject("frmChildForm") loChildForm.Setup(this) loChildForm.Show()
In your child form Setup() method:
lparameter loCallingForm This.CallingForm = loCallingForm
So now your child form has a reference back to the form that called it. So on your child form you can now do:
thisform.CallingForm.SetTextbox("hello")
I can email you a little demo project if you like.
I would do it this way:
On your first form, put a button to call the second form. In the button's click event do this:
do form secondform with thisform
On the second form init event:
lparameters toForm
thisform.oForm = toForm (you created a property called oForm in the second form and attach the parameter to it)
the second form should be modal. Then you make whatever changes you need.
When you completed your changes, I assume you typed something in a textbox (named txtWhatIType in this example)
thisform.oForm.text1.value = thisform.txtWhatIType.value thisform.oForm.text1.refresh
release thisform
What you have done here is send a reference to the first form to the second form (thisform). It gets into the second from in its init event and is captured in the second form oForm property
When you finish your changes, you pass the value of those changes from the txtWhatIType textbox into text1 (or whatever you named it) in form 1. Just in case, but perhaps not necessary, you refresh the first form's text1.value
You release the second form and you should have the value you want in the first form
Rafael Copquin
If the second form isn't modal, you'll need to account for dangling references. I suspect it will be modal. If not let us know.
Tracy Pearson PowerChurch Software
This tip below reminds me of that phrase years ago by Ed or Ted or somebody else that said "program to the interface, not the implementation."
Alan's example was very good and not cluttered.
On 2016-07-06 09:50, rafael copquin wrote:
I would do it this way:
On your first form, put a button to call the second form. In the button's click event do this:
do form secondform with thisform
On the second form init event:
lparameters toForm
thisform.oForm = toForm (you created a property called oForm in the second form and attach the parameter to it)
the second form should be modal. Then you make whatever changes you need.
When you completed your changes, I assume you typed something in a textbox (named txtWhatIType in this example)
thisform.oForm.text1.value = thisform.txtWhatIType.value thisform.oForm.text1.refresh
release thisform
What you have done here is send a reference to the first form to the second form (thisform). It gets into the second from in its init event and is captured in the second form oForm property
When you finish your changes, you pass the value of those changes from the txtWhatIType textbox into text1 (or whatever you named it) in form
- Just in case, but perhaps not necessary, you refresh the first
form's text1.value
You release the second form and you should have the value you want in the first form
Rafael Copquin
[excessive quoting removed by server]
On Jul 6, 2016, at 2:09 PM, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
This tip below reminds me of that phrase years ago by Ed or Ted or somebody else that said "program to the interface, not the implementation."
I know I've said it, and I know Ted's said it, and so have many others. It is excellent advice.
-- Ed Leafe
--- StripMime Report -- processed MIME parts --- multipart/signed text/plain (text body -- kept) application/pgp-signature ---
On Wed, Jul 6, 2016 at 4:51 PM, Edward Leafe ed@leafe.com wrote:
On Jul 6, 2016, at 2:09 PM, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
This tip below reminds me of that phrase years ago by Ed or Ted or somebody else that said "program to the interface, not the implementation."
I know I've said it, and I know Ted's said it, and so have many others. It is excellent advice.
'Tis. I'm pretty sure I learned it from Steven Black, who 'got' OOP long before I did.
He, in turn, is likely to have picked it up from Eric Gamma, of the Gang of Four:
http://www.artima.com/lejava/articles/designprinciples.html
It's a key idea behind object orientation: don't tell objects what code to run, send a message to them telling them what result you're after, and leave the implementation to the object (information hiding).
On 2016-07-06 17:01, Ted Roche wrote:
On Wed, Jul 6, 2016 at 4:51 PM, Edward Leafe ed@leafe.com wrote:
I know I've said it, and I know Ted's said it, and so have many others. It is excellent advice.
'Tis. I'm pretty sure I learned it from Steven Black, who 'got' OOP long before I did.
He, in turn, is likely to have picked it up from Eric Gamma, of the Gang of Four:
http://www.artima.com/lejava/articles/designprinciples.html
It's a key idea behind object orientation: don't tell objects what code to run, send a message to them telling them what result you're after, and leave the implementation to the object (information hiding).
One of the great benefits--as I used to preach at Central PA VFP Users Group in my OOP sessions--was that the code was easily portable.
"Program to an interface, not an implementation" is the first principle espoused by the Gang of Four (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) in their 1995 book (and OOP bible), Design Patterns: Elements of Reusable Object-Oriented Software. So I think a lot of us have said it!
Mike
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Edward Leafe Sent: Wednesday, July 06, 2016 2:52 PM To: profoxtech@leafe.com Subject: Re: updating 2 forms
On Jul 6, 2016, at 2:09 PM, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
This tip below reminds me of that phrase years ago by Ed or Ted or
somebody else that said "program to the interface, not the implementation."
I know I've said it, and I know Ted's said it, and so have many others. It is excellent advice.
-- Ed Leafe
--- StripMime Report -- processed MIME parts --- multipart/signed text/plain (text body -- kept) application/pgp-signature ---
[excessive quoting removed by server]
On 2016-07-06 16:51, Edward Leafe wrote:
On Jul 6, 2016, at 2:09 PM, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
This tip below reminds me of that phrase years ago by Ed or Ted or somebody else that said "program to the interface, not the implementation."
I know I've said it, and I know Ted's said it, and so have many others. It is excellent advice.
Worst code I saw was years ago when this guy had passed forms to the business objects and was coding to the implementation (thisform.pageframe.page99.pageframe1.page999.grd.Crap.header1.fontbold = ....) lol
Thankfully I quit that nightmare after about 4 months. Every day was a freakin' chinese fire drill and data crisis situation. My boss--who had been bought a beautiful new Lexus RX at the time (so that the company didn't lose her)--ripped me a new one for using ASSERTs in my code, thinking the customers were going to see the messages. She'd read the first line of my email and then shout over the cubes asking me all kinds of questions that were answered beyond that first sentence. She was a former professional bowler I was told....she should have stuck to that.