Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Refresh Data on Form A while working in Form B

Posted on 2006-06-28
7
Medium Priority
?
324 Views
Last Modified: 2010-04-23
I have a MDI program that has multiple screens.  But what I am most concerned with is form A and Form B inside the MDI Parent.

Form A opens when the MDI program starts and the end user will open Form B and make changes.

How can I get Form A to update its fields / Data with the changes that Form B has made?

Thanks
0
Comment
Question by:danorme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 34

Expert Comment

by:Sancler
ID: 17005377
If you are accessing the same data from a number of forms the best idea is to hold that data somewhere (a module? a public class?) from which it accessible to all the forms.  Then if form A's controls are bound to a datatable which form B updates the updates are immediately reflected in form A's controls without any further action on your part.  Would that be viable in your setup?

Roger
0
 

Author Comment

by:danorme
ID: 17005602
It is by all means the best way to do it, but I am too deep into this to make that type of change.  Version 3 of this program, already started, will use this for sure.  Can you assist with band aid, so to speak?
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17005744
I'm off to bed now - in the UK, where I am, it's just after midnight - and detailed suggestions would depend on details of your set up which I don't know.  But the basic issue is one of communication between form B and form A.  Somehow, form B needs to tell form A "I've made changes, you'd better use your own mechanisms for updating".  That suggests either adding a public Event to form B which fires when it makes changes and which form A or the MDI parent can listen for.  Or using the link from form B to its MDIParent and from that to its MDIChidren to pass a message direct to form A.

I'm not sure if that will be enough for you to sort something out.  But if not, post some details of how you call forms A and B, and whether form B stays open when it has done its update or its closing might provide a sufficient trigger for form A to update, and that sort of thing and I'll check in again in the morning.  If it's not resolved (by you or someone else on here) by then, I'll see what I can do.

G'nite ;-)

Roger
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 34

Expert Comment

by:Sancler
ID: 17005778
A quick thought.

A public Boolean variable "DataDirty" in the MDIParent.

When B changes the data it sets

     Me.MDIParent.DataDirty = True

When A becomes active again it runs

    If Me.MDIParent.DataDirty Then
          'updating code
   End If

Now I really must go to bed ;-)

Roger
0
 

Author Comment

by:danorme
ID: 17006418
I think I might try something like this, it is 9:26pm now, in the morning.  The way I set this thing up was when I first began programming so you can guess that it is UGLY!  Now Version 3 will be cleaner and a lot more efficient, but still done by a person that has a year of programming under his belt, although 15 years of networking and server administration.

Here is what I have so far.  Really the MDIParent is just a holder of other forms and that is really it.  Each form acts almost independently of each other, my mistake.  I am using ADO.NET (disconnected) which has been a new thing for me since I am used to using straight SQL statements.
So let me see if I get this right.

I can do something like this.
>>>Form B<<<
If DataSetA.HasChanges Then
Me.MDIParent.DataDirty = True
End If

>>>Form A<<<
If Me.MDIParent.DataDirty = True Then
DataSetA.Clear
sqlDataAdapater.Fill(DataSetA.MyTable)
End If

Would something like this work?

Good night?
0
 
LVL 34

Accepted Solution

by:
Sancler earned 2000 total points
ID: 17007405
It might.  That's certainly on the lines of my last post.  I note, however, that

1)  the code in Form B does not actually show an .Update being performed on DataSetA.  If that is not done (and assuming that DataSetA in Form B is different from DataSetA in Form A - see next comment) then the database itself will not show the changed data so refilling the dataset in Form A will not show the changes.

2)  the code from both Form A and Form B refer to DataSetA.  These could be different objects - one declared in Form A and Form B - in which case see the comment above.  But if they are one and the same object - declared at Project level - then any change made to it by one form should automatically be reflected in the other form even before any .Update is performed on it.

3)  on this approach - although I didn't specifically say this - you ought on Form A, besides clearing and re-filling its dataset, to re-set the DataDirty flag to False.

Roger
0
 

Author Comment

by:danorme
ID: 17009570
Ok, I will give this a try today and let ya know.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 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