|
-
Apr 27th, 2005, 04:45 PM
#1
Thread Starter
Member
[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
-
Apr 27th, 2005, 05:34 PM
#2
Frenzied Member
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?
-
Apr 27th, 2005, 06:03 PM
#3
Thread Starter
Member
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.
-
Apr 27th, 2005, 08:50 PM
#4
PowerPoster
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:
Dim frm2 As New fclsForm2
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.
-
Apr 28th, 2005, 04:22 AM
#5
Thread Starter
Member
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 !
-
Apr 28th, 2005, 04:24 AM
#6
Frenzied Member
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...
-
Apr 28th, 2005, 11:00 AM
#7
PowerPoster
Re: How to load data in second Form ??
 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:
Dim frm2 As New fclsForm2
Me.Hide
frm2.ShowDialog()
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.
-
Apr 29th, 2005, 02:47 AM
#8
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|