Accessing a variable declared in another form

Can someone tell me how I access a variable outside from the form it was declared in? I've tried examples but they haven't worked.

There are many right ways and many wrong ways to do what you want, the two below (one code example) and one link to a demo project are but two ways to do this.
A simple example, form1 as two buttons, form2, two buttons, one text box. This replies on knowing the parent form.
Public Class Form1
Public SomeVar As String = "Karen"
Public Property SomeProp As Integer = 4
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim f As New Form2 With {.Owner = Me}
Try
f.ShowDialog()
Finally
f.Dispose()
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MessageBox.Show(Me.SomeVar)
End Sub
End Class
Form2
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim MyParent As Form1 = CType(Me.Owner, Form1)
MessageBox.Show(MyParent.SomeProp.ToString & Environment.NewLine & MyParent.SomeVar)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim MyParent As Form1 = CType(Me.Owner, Form1)
MyParent.SomeVar = Me.TextBox1.Text
End Sub
End Class
The following link has a project which is much more involved, I allow non-modal forms to pass data between the two in real time and both forms stick to each other.
https://onedrive.live.com/redir?resid=a3d5a9a9a28080d1!727&authkey=!AEQ4n6P1H4sD6QI&ithint=file%2czip
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

Similar Messages

  • Access a variable in the Adobe form for Java Scripting

    Hi,
    I am unable to know how to access the variable in a Adobe form.
    The variable is field of an internal table. My adobe form structure is as follows
    MAIN_PAGE->FORMSET->FirstFORM->EXT.
    in the EXT subform the variable(cust)  exists.
    The cust is in turn an internal table.

    Hello Sreelatha,
    I think we cannot hide a page.  as in, page is the main container.  In a container, we can hide any field using some scripting.  Even though if we hide the field, it is present on page but not visible. 
    but if some logic is there, please let me know.
    Thanks,
    Rakesh.
    Edited by: rakhi966 on Sep 8, 2011 8:54 PM

  • Variables Declaration in ORACLE Forms Builder 10g

    Dear Sir/Madam.
    I am new in Oracle developer suit(Forms builder 10g) .
    I want to declare three variables in Forms builder and when I press the button it will execute the querey/ retrieve data from the specific table.
    Table name= department
    Column names : dept_code number(5), dept_name varchar2(20), dept_location varchar2(25)
    Database User name; yassen
    database : test.
    Please help me to understand this problem.
    Thanks and regards,
    Ghulam Yassen
    Edited by: Ghulam Yassen on Oct 6, 2011 3:46 PM

    Yassen,
    Try,
    DECLARE
      Num_Code DEPARTMENT.DEPT_CODE%TYPE;
      Str_name  DEPARTMENT.DEPT_NAME%TYPE;
      Str_Location DEPARTMENT.DEPT_LOCATION%TYPE;
    BEGIN
       SELECT DEPT_CODE, DEPT_NAME, DEPT_LOCATION INTO Num_Code, Str_name, Str_Location FROM DEPARTMENT WHERE DEPT_CODE = <your_value>;
    END;Hope this helps.
    Regards,
    Manu.

  • How to access a variable from inside another symbol

    So i did this tutorial, Leveraging Independent Symbol Timelines created by Eliane...it's rockin, btw.  ;-)
    All's well but now i have a symbol on the stage called mc-home.  inside of mc-home is a button called btn-go.
    On the stage in composition ready there's a variable sym.setVariable("current", "mc-home");
    This code works for a symbol that's on the stage but, how do i get this code to work on a button that's inside another symbol that's on the stage?
    var current = sym.getVariable("current");
    if (current != "") {
        sym.getSymbol(current).play("OUT");
    sym.getSymbol("mc-something").play("IN");
    sym.setVariable("current", "mc-something");

    sorry, i was kind of confused myself too, don't worry about it but thanks for your patience for reading it anyway

  • Using xsl:import and trying to access a variable defined in another xsl

    Hi
    I am having a a.xsl file with contents liek this :
    <xsl:variable name="PersonId" select="'1910'"/>
    inside b.xsl i am importing a.xsl like
    <xsl:import href="a.xsl"/>
    <xsl:value-of select="$PersonId"/>
    This is working fine when i am testing it standalone.
    when i port the code to weblogic server (meaning when all the
    project related files are placed in proper location in
    weblogic) and start the application then i get the error msg :
    xsl:1031 variable not defined 'PersonId'.
    i tried giving the enite path like :http://localhost:7001/....
    even then problem remains unresolved.
    am i making any mistake ?
    Thank you
    Regards
    Jaya

    This works fine for me with Oracle XSL Processor 9.0.2C
    <!-- a.xsl -->
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:variable name="PersonId" select="1910"/>
    </xsl:stylesheet>and
    <!-- b.xsl -->
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:import href="a.xsl"/>
      <xsl:template match="/">
       <xsl:value-of select="$PersonId"/>
      </xsl:template>
    </xsl:stylesheet>Make sure you're using the latest version of the XDK in your
    weblogic environment.

  • Forms 9i accessing package variables

    I created a package in my sql session which contains only variables. When I connect to the database through Oracle Forms and try to access these variables in a trigger I receive the error "Cannot directly access remote package variables or cursor" How can I access these variables from within a forms module?

    You cannot access package variable or constants directly from a remote PL/SQL client. Only PL/SQL running on the server can access these. You need to implement get and set methods in the package.

  • Using a static variable declared in an applet in another class

    Hi guys,
    I created an applet and i want to use one of the static variables declared in teh applet class in another class i have. however i get an error when i try to do that...
    in my Return2 class i try to call the variable infoPanel (declared as a static JPanel in myApplet...myApplet is set up like so:
    public class myApplet extends JApplet implements ActionListener, ListSelectionListener
    here are some of the lines causing a problem in the Return2 class:
    myApplet.infoPanel.removeAll();
    myApplet.infoPanel.add(functionForm2.smgframeold);
    myApplet.infoPanel.validate();
    myApplet.infoPanel.repaint();
    here are some of the errors i get
    dummy/Return2.java [211:1] package myApplet does not exist
    myApplet.infoPanel.removeAll();
    ^
    dummy/Return2.java [212:1] package myApplet does not exist
    myApplet.infoPanel.add(functionForm2.smgframeold);
    ^
    dummy/Return2.java [213:1] package myApplet does not exist
    myApplet.infoPanel.validate();
    ^
    dummy/Return2.java [214:1] package myApplet does not exist
    myApplet.infoPanel.repaint();
    ^
    please help! thanks :)

    I don't declare any packages though....i think it just doesn't recognize myApplet for some reason..
    other errors i got compiling are:
    dummy/Return2.java [82:1] cannot resolve symbol
    symbol : variable myApplet
    location: class Return2
    updateDesc.setString(3, myApplet.staticName);
    I Don't get why i'm getting this error cuase they worked fine when myApplet was a standalone application, not an applet.
    myApplet is in the same folder as Return2 and it compiles properly.

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

  • How to call to another form declare in different class ???????

    hi, i'm beginner in j2me...
    I was wondering how to call to other form(class) in the current form...
    For example,
    public class A extends MIDlet implements CommandListener
    public void commandAction(Command d,Displayable s)
    if (d==*OKCommand*)
    if press this OK command, it will be able to show another form declared in the different class...
    How to make it able to call to other form/class(eg.classB)????
    public class B
    //form that will be shown after pressed command OK in class A
    please help if you know...Thanks a lot..... =)

    you MUST have a reference to the other class or MIDlet in the current MIDlet ...
    i think that i have answered to these kind of questions a few month ago.. you should use the 'search' engine to find the topic..
    CLDC and MIDP forum is not a huge forum compare to Java Programming forum so it will be easy !

  • How to access Workflow variables in Form Designer?

    Hello,
    I am wanting to set certain subforms to readonly depending on which part of the workflow the form is currently on. I already have the JavaScript code working to set the subform fields to readonly, but now I cannot figure out how to trigger this and where do I keep a variable to keep track of which part of the workflow I am currently in.
    I assume I will have a variable in the workflow itself and then I can use the Set Value QPAC to change the variable for each workflow step before it goes to the User QPAC, but what about within the form? I don't understand how the form javascript will know to execute, so how does my workflow "talk" to the form to set these fields to readonly?
    Right now the JavaScript code is sitting in the root::initialize part of the form. I was assuming I could have something like "if my workflow variable is equal to XX then set this subform to read only". But, how do I access my workflow variable in the form designer?
    Also, since I have digital signatures, I am having to pass all the form data in document variables, will this affect how I need to do this? I was also thinking of possibly accessing/setting a hidden field in the form, but thought the above way may be better.
    I hope that made sense!
    Thank you,
    Jennifer

    To follow-up, I spoke with Adobe support this morning and they said that I cannot access Workflow variables within Designer (besides those Workflow variables that are already provided).
    He mentioned that if I use the hidden fields, that I would need to Render the form each time before going to the User to trigger this to happen. So, I am not sure what I will do just yet. I probably not worry about making the fields readonly for the time being; it was a little extra thought I had and isn't required for our process.
    Thank you,
    Jennifer

  • Pass Global Variables to another forms(urgent)

    Hi,
    Can someone tell me what is the best way to pass a global variable from one form to another forms. I havn't trouble with that.
    Please advise.
    Thank you very much
    Tim
    null

    You can use a parameter.
    Helena
    null

  • Accessing SPML Object class variable on SUN IDM Form or workflow

    Hi All,
    Can anyone suggest me how we can access the SPML variable on SUN IDM Form and workflow?
    e.g
    I have object class deffination in SPML configuration with schema deffination as below
    <Configuration name='SPML'>
    <Extension>
    <Object> <Attribute name='classes'>
    <List>
    <Object name='person'>
    <Attribute name='type' value='User'/>
    <Attribute name='form' value='SPMLPerson'/>
    <Attribute name='default' value='true'/>
    <Attribute name='identifier' value='uid'/>
    </Object>
    </List>
    </Attribute>
    <Attribute name='schemas'>
    <List>
    <String>
    <![CDATA[
                       <schema xmlns="urn:oasis:names:tc:SPML:1:0"
                      ...SPML standard schema...
                      </schema>
                       ]]>
    </String>
    <String>
    <![CDATA[
                       <schema xmlns="urn:oasis:names:tc:SPML:1:0"
                       ...Waveset custom schema...
                       </schema>
                       ]]>
    </String>
    </List>
    </Attribute>
    </Object>
    </Extension>
    </Configuration>
    Where I deffine my custom schema with all attributes that I want to view on SUN IDM custom form.
    I am able to set value from ModifyRequest for the variable but not able to get it on the Form or workflow.
    I did try with below expression to get the variable but no luck.
    <ref>attribute_name</ref>
    <ref>SPML.attribute_name</ref>
    <ref>SPML.Object_name.attribute_name</ref>
    Please suggest how we can access the variable?
    Any information will be appricated.
    Regards,
    vinash

    Hi All,
    Can anyone suggest me how we can access the SPML variable on SUN IDM Form and workflow?
    e.g
    I have object class deffination in SPML configuration with schema deffination as below
    <Configuration name='SPML'>
    <Extension>
    <Object> <Attribute name='classes'>
    <List>
    <Object name='person'>
    <Attribute name='type' value='User'/>
    <Attribute name='form' value='SPMLPerson'/>
    <Attribute name='default' value='true'/>
    <Attribute name='identifier' value='uid'/>
    </Object>
    </List>
    </Attribute>
    <Attribute name='schemas'>
    <List>
    <String>
    <![CDATA[
                       <schema xmlns="urn:oasis:names:tc:SPML:1:0"
                      ...SPML standard schema...
                      </schema>
                       ]]>
    </String>
    <String>
    <![CDATA[
                       <schema xmlns="urn:oasis:names:tc:SPML:1:0"
                       ...Waveset custom schema...
                       </schema>
                       ]]>
    </String>
    </List>
    </Attribute>
    </Object>
    </Extension>
    </Configuration>
    Where I deffine my custom schema with all attributes that I want to view on SUN IDM custom form.
    I am able to set value from ModifyRequest for the variable but not able to get it on the Form or workflow.
    I did try with below expression to get the variable but no luck.
    <ref>attribute_name</ref>
    <ref>SPML.attribute_name</ref>
    <ref>SPML.Object_name.attribute_name</ref>
    Please suggest how we can access the variable?
    Any information will be appricated.
    Regards,
    vinash

  • Access bind variables in forms

    Hi,
    I have declared a bind variable called :cal_group in sql query of a calendar and i added the calendar as a portlet to a page. And i set the value of the bind variable in the Page parameters section in which this appears as a portlet parameter. Now, I have a form which is called from this page. And i want one of the fields in the form to be prepopulated with this bind variable value. How can i do this. Any ideas greatly appreciated ! Thank you.
    --LG                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hello sharmila,
    Thank you for the response. Can you please give me an example. It would be very helpful to me. I was wondering how the form recognizes the variables declared in the calendar. Regards,
    --LG                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Control access of a form from another form.

    hi all,
    Please help me .
    This is a system which contains a lot of forms (more than 100) . The system administrator can specify whether a user can insert, update,delete or query for each form (this varies for each user). So, when a user logs in and calls a form i have to enable / disable the insert, update,delete or query according to the user who has logged in and the privileges the system administrator has given for that form.
    i used the call_form method with query_only mode and no_query_only(normal mode) option . The normal mode allows insert,update,delete and query together but i want the user to insert into database without querying any of the records.
    So, in short , i would like to know if i can enable/disable insert,update,delete & query of a called form(Form B) from calling form (Form A) without having to modify (Form B) and without issuing any grant statements in the database side ? Is there any option like the one in the call form method?
    Thanking you in advance.

    Thank you very much for the response.
    yes, set form property and set block property can be used when i want to enable / disable insert in the current form. But, what if i want to control enable/disable insert from another form (the main form) ????
    Can i pass parameters ? without making any change in the current form.

  • Accessing a variable form a super class

    Hi guys, its my first post in this forum, i am student and learning some java. I find it very interesting but have some problems
    My question is : How to access a variable from a superclass
    Here is my program:
    class superclass
         int i = 10, j= 20;
         void display()
         System.out.println("i in super is:" +i);
         System.out.println("j in super is:" +j);
    class child extends superclass
         int i,j;
         void display()
         System.out.println("i in child is:" +i);
         System.out.println("j in child is:" +j);
    class prgdemo
         public static void main(String args[])
         superclass s =new superclass();
         s.display();
         child c = new child();
         c.display();
    }Thanks for your replies

    This is only true of nested subclasses. Private
    fields are HIDDEN to ALL code contained outside of
    the enclosing class.You are a very bad racist man:class superclass {
         private int i = 10;
         private int j= 20;
         public class child extends superclass
              int i= 42,j= 54;
              void display()
              System.out.println("i in child is:" +i);
              System.out.println("j in child is:" +j);
              System.out.println("super's i is:" +super.i);
              System.out.println("super's j is:" + super.j);
              System.out.println("outer's i is:" + superclass.this.i);
              System.out.println("outer's j is:" + superclass.this.j);
         void display()
         System.out.println("i in super is:" +i);
         System.out.println("j in super is:" +j);
    }kind regards,
    Jos (eeeww!)

Maybe you are looking for