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

Form and subforms relation

Status
Not open for further replies.

speedovic

Technical User
Jun 16, 2008
4
NL
I have one MAIN form and many subforms linked to many tables using tabs.
I have used buttons to filter data so the user can alter the records easily. Nice!

Now I want to have one subform linked to 2 tables. For example: I have Table-A and Table-B
--> if the user click on button (A) the subfrom displays data from Table-A so user can make changes etc and
--> if user click on button B the SAME sufrom displays data from Table-B.

I am sure some has done this before so he/she can tell me how to do it.
Thanks a million for your help
************
 
You may consider the SourceObject property.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya speedovic . . .

You can have both subforms on the same tab with one hidden and one showing by default. Then your buttons hide and show the proper subforms. See the forms [blue]Visible[/blue] property for info on this.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
==> You may consider the SourceObject property.
you refer to the button or the subform SourceObject?
 
TheAceMan1,

It sounds good idea, I tried it manually it works fine one subform is hidden and the other one is shown at the same time.
This is the simple code I use in my buttons
===========================
Private Sub Knop112_Click()
Me.Filter = "[klas] = '2A1A'"
Me.FilterOn = True
End Sub
=============================
Say my sub forms are subformA and subformB; subformA is displayed and I want to make it hidden and turn subformB unhidden. As my vb knowldge is "0" I tried something like this but I had no success. I am asking again for help on how to insert the correct code..
Thx and I really appreciate your answers.
 
TheAceMan1,

I think I find it.. something like this may resolve the problem
Me.subformA.Visible = False (to hide)
Me.subformA.Visible = True (to unhide)

Thx
*******
 
or to toggle , use...

Me.subformA.Visible = not(Me.subformA.Visible)


Ian Mayor (UK)
Program Error
If people say I have bad breath, then why do they continue to ask me questions and expect me to answer them?
 
speedovic . . .

Here's an example that uses one button to toggle back & forth between the subforms and sets the caption of the button proper.
[ol][li]Open the mainform is design view.[/li]
[li]Set the [blue]Visible[/blue] property of [blue]subformB[/blue] to [blue]No[/blue].[/li]
[li]Set the [blue]Caption[/blue] of one of the buttons to:
[blue]View subformB[/blue][/li]
[li]In the [blue]On Click[/blue] event of the same button, copy/paste the following:
Code:
[blue]   If Me![[purple][B][I]ButtonName[/I][/B][/purple]].Caption = "View subformB" Then
      Me!subformB.Visible = True
      Me!subformA.Visible = False
      Me![[purple][B][I]ButtonName[/I][/B][/purple]].Caption = "View subformA"
   Else
      Me!subformA.Visible = True
      Me!subformB.Visible = False
      Me![[purple][B][I]ButtonName[/I][/B][/purple]].Caption = "View subformB"
   End If[/blue]
[/li][/ol]
Thats it ... give it a shot!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top