Results 1 to 8 of 8

Thread: [RESOLVED] How to load data in second Form ??

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    52

    Thumbs up [RESOLVED] How to load data in second Form ??

    hi,

    I have an application with 2 forms.
    -Form 1 : searches the account in the database;
    -Form 2: display account information (ex. account name, address etc) in Datagrids and Text boxes.

    My idea is, once the customer is known on Form 1 , I need to automatically Load the corresponding data (ex. account name, address etc) in Form 2.

    So far I have not been able to do it automatically, so I had to create a command button on Form2, to load the data.

    Any ideas on how to do it? (without using the Load button on Form2)

    Thanks,
    Joao
    Last edited by jfortes; Apr 29th, 2005 at 02:45 AM. Reason: RESOLVED

  2. #2
    Frenzied Member dinosaur_uk's Avatar
    Join Date
    Sep 2004
    Location
    Jurassic Park
    Posts
    1,098

    Re: How to load data in second Form ??

    When you load the account, doesn't that trigger an event?

    Is form2 already loaded, or do you want it to automatically load up?

    is it a MDI form?

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    52

    Re: How to load data in second Form ??

    hi,

    I first search the account on the database based on the information typed on Form1. Don't know if the account search, generates an event . How can I find that out ?

    Form2 is a standard SDI Form.

    On Form2, i have some SqlCommands that need the customer id (from Form1) as input.

    I'm not able to load Form2, by running the Sql statements . I tried instantiating the Form2 and call the Form_Load procedure, but it doesn't work either.

    Joao.

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: How to load data in second Form ??

    Hi,

    First of all, to access objects on other forms look in the codebank at

    http://www.vbforums.com/showthread.php?t=313050

    Second, the actual searching of the account in form1 IS initiated by an event. That event may be a Search button or may be the Load or Activated events of the form. If you want to progress to form2 immediately the account data has been collected, then (assuming that the search was generated by a button) put the code starting form2 at the end of the other code in that button. Something like:

    VB Code:
    1. Dim frm2 As New fclsForm2
    2. frm2.ShowDialog()

    Then in the Load event of fclsForm2 put your code to refer to the values in form1 and apply them to the database.

    Hope that helps.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    52

    Re: How to load data in second Form ??

    Thanks so much it worked just fine.

    The only problem now, is when i do a Frm2.ShowDialog() , the Form1 is still opened in the background.
    How can I close Form1 once Form2 is loaded ?
    Tried Close() , but it does not work . Form1 is just closed when Form2 is closed also !

  6. #6
    Frenzied Member dinosaur_uk's Avatar
    Join Date
    Sep 2004
    Location
    Jurassic Park
    Posts
    1,098

    Re: How to load data in second Form ??

    I had the same problem too...

    I decided to go to the MDI forms route

    it is alot easier and more organised...

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: How to load data in second Form ??

    Quote Originally Posted by jfortes
    Thanks so much it worked just fine.

    The only problem now, is when i do a Frm2.ShowDialog() , the Form1 is still opened in the background.
    How can I close Form1 once Form2 is loaded ?
    Tried Close() , but it does not work . Form1 is just closed when Form2 is closed also !
    What do you want to do? Keep form1 open but invisible? If so amend the code to

    VB Code:
    1. Dim frm2 As New fclsForm2
    2. Me.Hide
    3. frm2.ShowDialog()
    4. Me.Show
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  8. #8

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    52

    Re: [RESOLVED] How to load data in second Form ??

    Thanks so much, i will implement this change.
    I've set the status of this thread to "resolved".

    João.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width