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

Subforms 1

Status
Not open for further replies.

janetlyn

Technical User
Jan 29, 2003
516
US
I have not used subforms very frequently, but if I have 6 tables with the same field being the primary key in all 6 tables (i.e. Project#), Can I have one main form with 5 subforms (hidden maybe) so when I add a new project# to the main table, it automatically adds the same project# to the subforms. All the tables are a one-to-one.

I would appreciate any thoughts on this matter. Thanks, JL
 
Just make sure that when you insert the subform set the "Link child fields" and "Link master fields" properties to the field that is your primary key in both recordsets.

HTH,
Eric
 
Eric, thank you. I may have some more questions regarding this subject, but I'm just happy to know it is possible so I can get started organizing my DB to be a little bit (well, a lot) more user-friendly. I'll make sure to do what you suggested. Janet Lyn
 
Okay, I have a tab control with the first page containing my parent form (P1). I have a tab-control below with 5 tabs, each having a subform which is the 5 "children". The directions said to turn on the wizard and select F11, which I did, which is how I got all the children in the tab controls. However, I do not believe they know they are the children of P1 because when I go to the second tab (P2) on the parent control the children tab from P1 are still visible. So I came back to read your directions and would like to know how to ""set the "Link child fields" and "Link master fields" properties "" as you stated I should do.

Wow, this is like learning Access all over again; or at least a whole new area. Thanks for your help, JL
 
There are two property menus for your subform. One is the subform's form properties. The other is the subform control properties. You will need to access the control properties. In design view, click the subform control once so that the object is selected. Go to view\properties. Select the data tab. Enter your fields as advised above.

HTH,
Eric [smile]
 
I believe I am trying to mix to many variables into the mix at one time. My main form is connected to Tab1 and my 5 children forms on connected to another Tab Control each with its own tab. So, actually both my Tab Controls are part of the Parent form, and the tabs for the bottom Tab control are the children. The key for each table "form" is Project#. However, when I try and select "Link Child Fields" or Master fields it gives me an error that the expression I'm using doesn't exist or is closed. Should the bottom tab control be a complete separate form itself? And then make that form the subform with the five tabs being sub-sub forms? Man, this is confusing. Looks good though. HA. Thanks for the help, JL
 
I think I understand what you have done and I don't believe it will work how you want the way you have it.

The subform should be within the main form so that it is a control in the main form. By placing the main form on a tab in a tab control and the sub forms in another tab within the same tab control, both the main form and your subforms are child forms to the form that contains the tab control. (I hope that makes sense [smile])

You will need to place your subforms within the main form (probably detail section)to get the results that you want.

Let me know if I understood you situation correctly.

HTH,
Eric
 
I see what you are saying. This is like my 3th design of this stupid db, and while I'm changing design I'm also adding forms and data to it. First, all my forms looked exactly alike, like web pages. Then I got up to 64 forms and some only contained a few lines of text so I started switching to make most of them popups. Then I stumbled somehow onto Tab Controls and like their neatness. So, what would you suggest for this:

Parent: Project No, Description
Child: Brochures, Table with three different choices
Child: Involvement, Table for all employees
Child: Costs, How much construction costs were broken down.

Parent: Help, all Tab Control with each tab being an alphabet.
On each tab is a label hyperlinked to a popup form. I don't like how this works or looks.

Parent: Accounting
Child: About 30 childs, each with its own form. Some are input forms, some I am changing to automatically open Excel files, etc.

I guess I want uniformity and cannot decide the best way with all the variables. I don't do this for a living, just for my work because my memory sucks and this way I can go to this program to find out anything I do.

Do you have any suggestions on how I could make everything easy to find and get to if my Tab Controls are not going to work? I appreciate any input you can give me.

Thanks, JL
 
Eric, I did what you said and have just one main form (M1). I have a Tab Control also on M1. There are six tabs with subforms in each one. On one of the subforms (S6) The user has a choice to select either of two checkboxes. If they select one they get a message telling them to select one of two buttons that are now visible. Those buttons make visible certain fields in S6's table/form. At the same time when it opens those fields, I want it to go to a new record. However, it keeps giving me an error that S6 form is not opened. Do I have to indicate somewhere that it is now a subform? Below is the code for one of the buttons they are to choose from:


Private Sub NewHours_Click()
REM Make visible those fields to add new records
Date.Visible = True
TtlAllow.Visible = True
CheckHours.Visible = True
CheckTrips.Visible = True
CkHours.Visible = True
CkTrips.Visible = True
lblHT.Visible = True
lblDate.Visible = True
lblTtlAllow.Visible = True
ANR.Visible = True
REM Make sure fields for using hours are not visible
lblMany.Visible = False
lblEmpIni.Visible = False
UseHoursTrips.Visible = False
EmpIni.Visible = False
ANR1.Visible = False
REM Open fields to a new record
DoCmd.GoToRecord acDataForm, "frm-ChildProjectObs", acNewRec
REM When opening to a new record go to the date field
Date.SetFocus
End Sub

Five of the subforms are one-to-one and this S6 is a one-to-many relationship. Could that be what is causing the problem? Is there anything apparent you can see that is causing this problem?

Thanks, JL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top