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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subform question 1

Status
Not open for further replies.

Kyosa

Technical User
Jun 12, 2000
47
US
i have a subform that is used in more than one main form. is there a way to tell the subform which main form is currently using it. (basicall y i'm wonderin if i can put a control on the subform that will change depending on which main form it's on at the time..) is that confusing???<br><br>anyway, any ideas would be GREATLY appreciated!!!!
 
In similar situations I've use global or public variable(s).&nbsp;&nbsp;I set the variable based on the calling form (or your main form) then in the subform (or other form called), I look for the contents of the variable, and set up my form to display the appropriate info.&nbsp;&nbsp;In your case a boolean variable would work, if true then form1 is the main form, if false then form2 is the main form.<br><br>HTH<br><br>PaulF
 
Thanks for the tip. i was thinking about something like that but i wasn't sure if there was a more direct way or not. I think the global variable route is the way i'm gonna end up going.<br><br>thanks again.
 
Another thing I just thought of is the IsLoaded function<br><br>you can test to see which Main form is open using the IsLoaded function and set up your subform based on that.&nbsp;&nbsp;Use the code in the On Load event for the subform<br><br>The following code checks to see if a form with the name frmMain1 is open and changes the caption based on the results.<br><br>Private Sub Form_Load()<br>If IsLoaded(&quot;frmMain1&quot;) Then<br>&nbsp;Label0.Caption = &quot;Form frmMain1 Loaded&quot;<br>Else<br>&nbsp;Label0.Caption = &quot;Form frmMain2 Loaded&quot;<br>End If<br>End Sub<br><br>This following is the IsLoaded function, if you don't already have it:<br><br><br>Function IsLoaded(ByVal strFormName As String) As Boolean<br>&nbsp;' Returns True if the specified form is open in Form view or Datasheet view.<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Const conObjStateClosed = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;Const conDesignView = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If SysCmd(acSysCmdGetObjectState, acForm, strFormName) &lt;&gt; conObjStateClosed Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If forms(strFormName).CurrentView &lt;&gt; conDesignView Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IsLoaded = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Function<br><br><br>Just Another way<br><br>PaulF<br>
 
wow, that's something i definitely would not have thought about! thanks again for the ideas!!!!
 
ok, god do i feel stupid. i'm trying to declare this here global variable using <br><br>public mainform as boolean<br><br>but there i try and check to see if it's tru or not i keep getting the error saying the variable isn't defined!!! what blatently obvious @@!%#^^ thing am i missing!!??? <br><br>( I NEED MORE COFFEE!!!!!!!!!!!)<br><br>
 
Use the .Parent property. Put this on the OnOpen of your subform, and you will see what I am talking about.<br><br>MsgBox Me.Parent.Name<br><br><br><br><br> <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
Jimmy,<br><br>That did it!!! that was the little trick i was hoping for!!!! thanks very much! i knew there had to be an &quot;easy&quot; way to do that!<br><br>-kyosa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top