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

Subforms help!

Status
Not open for further replies.

mattpearcey

Technical User
Mar 7, 2001
302
GB
I have a form set up that onthe top, states an id number that relates to a bank name, and the bank name itself. I want to use the form, and thus the sub form to record news items about each bank in a list(in the subform). I have created the subform but when i scroll through the banks the news items stay the same and dont change through the banks. This is a problem i need to sort as i want a few of the forms to take this structure.

Am i being completely stupid and is this an easy thing to rectify? Help needed?!

Kind regards

Matt
 
Hi Matt,
Click once on your subform thru your main form when in design view. Click on the properties button on your tool bar (hand holding paper). This will open the dialog for the sub forms properties. Now select the data tab and see what you have in "Link Child Fields" and "Link Master Fields". They should contain the fields that relate your main form (master) to the subform (child). You could click just to the right of either field on the ellipse "..." button and another small dialog will open to try and help you find the link. I am assuming here that your database is set up with One bank table (mainform) and another table (subform) for your Many bank news items. Give it a go! Gord
ghubbell@total.net
 
Gord

i think i have done what you suggested correctly, however, now it is asking me for parameter values for onw of the fields? which i have not set previously?

stuck - again!

help?

 
Matt:
Take a careful look at the field it is asking for. Make sure it exists and it is bound to your table and correctly named. Gord
ghubbell@total.net
 
Gord

I think that is all ok. I have now got the subform to show only that bank that i want, thus it should show the news for just that bank. However, everytime i scroll through the records it asks for to enter a parameter value for both my field; news, and information. When i enter something, it goes into those fields in the subform, but hen does not stay there. if i scroll again, i have to enter it again. All very confusing, as i am sure it is very easy to set up -for someone other than me know doubt!

Hope you can help yet again?

Thanks

Matt
 
If when you are scrolling through either the Bank records or the Banks notes records, the form(s) are re-gathering data to display to you. If your forms are running on queries, check the queries and see if they will run properly on their own. Also check each forms "Filter" and "Order By" properties. You can wipe them clean for the moment. We'll get it! Gord
ghubbell@total.net
 
The problem i am findong now, is when i add data, i think there is a problem with conflicts with the autonumber i have set for the bank id. as the following error message appears: "Changes requested to the table were not succesful because they would create duplicate values in the index, primary key, or relationship. change the data in the field or fields that conatin duplicate data, remove the index, or redifine the index to permit duplicate entries and try again."

Does this mean that all i need to do is remove the autonumber from the sub form as is realtes to the autonumber onthe main form, and is duplicating? Not sure?

Almost there!

Thanks in advance?

Matt
 
Your subforms table I will assume is linked as described before: It is the Many versus the One right? If so, you shouldn't be using an autonumber as its link to the "Parent". The parent can be the autonumber:
Bank1, ID 1 BankNoteA carries Bank1's ID and may also carry its own ID as an autonumber, but not as the link. Look at your tables and see if this is the case. If so, change your banknote connecting ID to "long integer".
Make sure its indexed property says "Yes (Duplicates OK)". Remember 1 bank can have Many notes so this table will see many entries with "BankID1" from Bank1.

You'll also need to set the default value of your BankID on the subform. Go thru the main form in design view, double-click to open (97) or click (2000) then double-click on your subforms BankID. This will bring up its properties dialog. Look at the Data tab, find default value, and using the ellipse "..." button just to the right of this field, open the builder. You want the default value to be something like:
=[Forms]![NameOfTheMainForm]![BankID]
So go to Forms-Loaded Forms-NameOfYourMainForm, then double-click on the list in the middle on your "BankID". You are almost there!


Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top