Switching between forms

Posted on 2007-10-09
Last Modified: 2010-04-30
Hi, learning VB 2005

In my app, I have 2 forms.

On form A, I want to click a button that directs the user to form B.

But I want to populate Form B with values entered into Form A.

How can I do that?

I tried something like this in the code for Form A

private buttonClick()

FormB.TextBox1 = FormA.TextBox1

But it doesn't recognize FormB

Question by:bdb12
    LVL 8

    Accepted Solution

    try to assign the value while the form is initialized (eg it's already displayed, like after
    LVL 8

    Expert Comment

    ah vb2005

    put a public function into formB, like

    public sub ShowData(myData)

    and display your data in that function. call the function from formA, feeding it with the data you want to be displayed.
    LVL 8

    Expert Comment


    public sub ShowData(myData as string)
    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    With VB.Net 2005, you should be able to just use the Forms name.  This is known as the "default instance" of the form.

    If it doesn't recognize "FormB" then either...

    (1) You have the name wrong.  Is it Form1 and Form2, as opposed to FormA and FormB?

    (2) You have disabled the Application Framework in the Project Properties?


    Author Comment


    in VB.NET you can just do there a similar way in VB 2005?

    Author Comment

    form names are pk and app framework enabled

    Author Comment

    working now thx

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Title # Comments Views Activity
    Problem to refer to cell 8 67
    Mysql vs Oracle 10 105
    Excel VBA combine two working workbooks 8 32
    MsgBox 2 28
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now