need help with subforms

Jon123

Registered User.
Local time
Today, 16:20
Joined
Aug 29, 2003
Messages
668
I have a main form with 2 subforms. On the mainform I have a PK autonumber called WCID and on the subforms I have a field callled section ID. The linking is setup as Main WCID and child is section ID. So when I enter data into the mainform it starts the WCID and when I enter data into a subform the child ID get updated and the same thing happens when I enter data into the second subform. But when I go into the table that the subforms report to there are 2 different records instead of 1 record. Why? the subform table looks like this f1 - f5 are on subform 1 and 6 - 10 are on subform 2
f1 f2 f3 f4 f5 f6 f7 f8 f9 f10
1 1 1 1 1
_ ________ 1 1 1 1 1
what do I need to do to get these both in the same record?
jon
 
Last edited:
I'm not sure I fully understand your issue but it sounds like when you add a record in subform 1 you need it to display in subform 2. In which case I'd say you need to requery subform 2 in an event in subform 1 like maybe the after update event.
 
no what I want is for the data entered into sub 1 and sub 2 to all be in 1 record in the table not split into 2 records.

jon
 
Your setup is working the way I would expect. Because each subform is linked separately to the main form, you will create a new record by entering data into each form. You need to change what you are doing. Your choices include (there may be others):
- Put all the fields into one subform
- Use one subform with two tabs
- Populate the PK field in the second subform from the PK field on the first and break the parent/child link in the second subform. This will only work if the first subform is populated first so that the PK is created.
- Make the subforms unbound and save the record using VBA
 
If he does the requery as I suggested I'd think it would work as well - ?
 
could you please explain a bit more on how to do the requery. if subform 1 has data then subform 2 is just adding more data to the same record right???
jon
 
Befroe we waste time on it I have one question: For each record on your main table form will you only have one record in your sub-form table?
 
correct 1 record in the main table and 1 record in the sub table
it will always be this way
 
So in the after update event of sub form 1 requery the second subform. Then you may also set the second subform where you can't do record additions, only edits. Make sense?
 
If he does the requery as I suggested I'd think it would work as well - ?
Not 100% sure. I think we might still get a second record created as soon as the second subform gets focus. Setting the subform to Allow Edits only might work, but I'm sceptical. The problem is that each subform is related to the main form and not to each other. Still not clear why we need two subforms.
 
when i set the subform to only allow edits then te form is not visible on the mainform????

jon
 
correct 1 record in the main table and 1 record in the sub table
it will always be this way

Why do you subforms and a sub tbl if the 2 tbls are 1:1.

Subforms are designed for 1 record in main tbl and several in the sub tbl ie 1 : many.
 
Last edited:
yes i agree but what I'm trying to do is have 1 main table and 1 subtable. A record in the subtable is being created by 2 subforms not when I fill out both subforms I get 2 seperate records in the subtable. I want the 2nd subform to put the its data into the record started by the 1st subform.

jon
 
You may need to requery the second sub form after the first subform is updated.
 
yes i agree but what I'm trying to do is have 1 main table and 1 subtable. A record in the subtable is being created by 2 subforms not when I fill out both subforms I get 2 seperate records in the subtable. I want the 2nd subform to put the its data into the record started by the 1st subform.

jon
Why? If you have a 1 to 1 relationship where there is always a record in each table, what is the point of having two tables - just have one.
 

Users who are viewing this thread

Back
Top Bottom