Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Forms beyond form 1 from code

Status
Not open for further replies.

RSH

Technical User
Jun 15, 2000
55
0
0
US
There must be a simple way to delete form 1 and go to form 2<br>from within basic. I would like to be able to use all my strings and variables but different objects on the second form. The change should be done with perhaps a command button.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;73 RSH
 
Make the form an MDI child.<br><br>declare all your variables at the form level.<br><br>When you load the form from the MDI form do it like this.<br><br>Dim f1 as new form1<br>Dim f2 as new form1<br>Dim f3 as new form1<br><br>you then get separate copies of the form, all can run, be unloaded etc independantly of each other<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Thanks for the tip.<br>Now all I have to do is find out what an MDI child is.<br>By poking around I have found how to get from one form to another with command buttons but the new form seems to be a private situation as non of the strings in the first form show up in form 2.&nbsp;&nbsp;Being an old basic man I shure wish that<br>VB was not so private.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;73&nbsp;&nbsp;RSH
 
&lt;grin&gt; sorry RSH<br><br>MDI forms are the &quot;background&quot; forms that hold the other forms an application has open. Like MS Word, it has what looks like an MDI form (with the menu's and all) and MDI children (open documents)<br><br>You can add an MDI form to a project with Project/Add MDI Form and you can then mark other forms as &quot;belonging&quot; to that MDI form by setting the form property &quot;MDI Child&quot; to true.<br><br>Hope this is clear, didn't mean to baffle you with Bull in my first post!<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
OK Mike:<br>I had discovered the MDI Child property. But the old VAIO<br>Complained that there was no MDI Form.&nbsp;&nbsp;Will persue this further with the above info.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;73&nbsp;&nbsp;RSH
 
PS:<br>I AM using the learning edition of VB. I assume that this version suports MDI.&nbsp;&nbsp;I can do what I wish but putting<br>all objects for both halves of the program on one template.<br>This however gets rather messy turning things on and off.<br>Much code.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;73&nbsp;&nbsp;RSH
 
RSH -<br><br>You can only set the MDI Child property after you have inserted a MDI parent form into your project.&nbsp;&nbsp;BTW, you can only have one MDI parent form in a project.<br><br>You've run into one of the thornier problems in VB -- one that we always ask new job applicants -- and that is how to get data from one form to another.&nbsp;&nbsp;At a minimum, you can:<br><br>1) Use Global variables<br>2) Use properties on callee form<br>3) Use public variables on callee form<br>4) Pass the data in as function parameters to a function/subroutine in the callee form<br>5) Send the data to a parent piece of code/form, and tell it to pass the data on to the other form on your behalf (the 'framework' technique)<br><br>and there are other variations on this.&nbsp;&nbsp;I've even seen people use a database to pass data around, but I think that is very poor practice because it's really slow. Of the techniques I listed, at my company we prefer to use properties on the callee form (#2), although we have been known to use #4, as well.<br><br>Chip H.<br>
 
Thanks Chiph:<br>Ill Print this out and look it over carefully. Its late at night.&nbsp;&nbsp;Maybe will go better in AM. At this time using just one form seems easier but one can get just so many objects on a form.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;73&nbsp;&nbsp;RSH
 
Hi Chip H, could you tell me something more about the

2) Use properties on the callee form and
4) Pass the data in as function parameters to a function/subroutine in the callee form

I am interested in knowing how exactly we do this within our forms.

I am very much interested in knowing it and for this i would be thankful to you.

Thanx in advance.
vijay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top