Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a form within a form 1

Status
Not open for further replies.

ejhemler

Programmer
Aug 30, 2002
68
US
i am trying to call a form "fpwmod" from another form "fpw004". i am have a button on the first form "fpw004" and in this buttons click event i used "do form fpwmod" to call the other form. then in the form "fpwmod" i am trying to assign a value to a text field "txtEmpNum" with the code

with thisform
.txtEmpNum.value = intEmpNum
endwith

however, i get an error "unknown member txtEmpNum" on the second line of the above code. does anyone know why i am getting this error? i also tried fpwmod in place of thisform in the first line and i get the error "variable 'fpwmod' is not found". thanks in advance.
erik
 
with thisform
.txtEmpNum.value = intEmpNum
endwith


The above code is refering to a field in which form? The txtEmpNum might be in the other form.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
with thisform
.txtEmpNum.value = intEmpNum
endwith

txtEmpNum is referring to a field in the second form "fpwmod". i called a user-defined method in the load event of fpwmod by "thisform.call_modify()". so if i can call fpwmod's methods with "thisform", then shouldn't i be able to call fpwmod's member's such as text field's with "thisform". i just don't get it. is there something i'm missing?
 
txtEmpNum is referring to a field in the second form "fpwmod". i called a user-defined method in the load event of fpwmod by "thisform.call_modify()". so if i can call fpwmod's methods with "thisform", then shouldn't i be able to call fpwmod's member's such as text field's with "thisform". i just don't get it. is there something i'm missing?

Yes, if you are refering to a member (object) within a form and the member is actually spelt that way, and your a calling it beyond the load event of the second form, then yes. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
In what method are you using your snippet? Load happens before Init, so at Load time, '.txtEmpNum' may not have been created, whereas the method has been.
Dave S.
 
i using the snippet in a method that I defined called call_modify(). i call this method from the load event. so i think what you are saying is right Dave. where do you suggest I put this method "call_modify()" because i need this method to run as the form is loading. should i put it in the init event?
erik
 
You will probably have to rethink your strategy. The Form Load event happens, then the Init of the objects on the form, then the form Init. So if that value needs to be created before txtEmpNum has been, you will probably have to use a public variable or form property in your method call to save it, then use it to set the value of the txt object after it has been created. Say, in the form init, or txtEmpNum init.
Dave S.
 
I know it may not be an elegant solution, but why don't you put the info into a public variable? Then put the info from the variable into the field when you get to tform that the field is on.

Good Luck [spidey] [americanflag] [unclesam]
 
using the snippet in a method that I defined called call_modify(). i call this method from the load event.

Try the init of the form instead. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
This is a good suggestion because the Init event is also the method that is given any parameters you pass to the form, such as:

DO FORM myform WITH param1, param2

Just put in your Init:

LPARAMETERS p1, p2
THISFORM.txtEmpNum.value = intEmpNum
* Maybe even:
THISFORM.txtEmpNum.value = p1
 
wgcs has the correct idea.

Whenever possible always pass data by parameters. Use globals only when there is no other solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top