Multiple subforms on one main form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to have mulitple subforms on one main form? I have the relationships set up so that each table used as a data source on each subform connects to the table of the main form in a one to many relationship. Whenever I try to add a second or third subform, however, Access changes the additional subforms to exact duplicates of the first subform. I would really like to have multiple subfoms (I'm using tabs for information about contacts) on a single form. Please help.
 
Catherine,

Yes, you can have multiple subforms on a main form. And I can't really
imagine what is happening with the behaviour you described. But getting
subforms onto the right spot on a tab control is not always a smooth
process. My suggestion would be, just for simplicity, to start again
with a clean slate, i.e. remove the tab control and subforms from the
form. Ok, then do it like this...
1. Put a Tab Control onto the main form, and set it up with the number
of pages you require.
2. Arrange your screen so you can see the form design and also the
Database Window at the same time.
3. Select the page on the tab control where the first subform is to go.
4. Go to the Database Window and find the name of the form which will
be the first subform.
5. Drag it from the Database Window to the from design, over to the tab
control, and wait until the the tab control page changes its background
colour.
6. Drop the subform.
7. Repeat steps 3-6 for each of the other subforms.
8. Set the Link Master Fields and Link Child Fields properties of the
subforms as applicable.

Please post back and let us know how you get on with this.
 
Catherine said:
Is it possible to have mulitple subforms on one main form? I have the relationships set up so that each table used as a data source on each subform connects to the table of the main form in a one to many relationship. Whenever I try to add a second or third subform, however, Access changes the additional subforms to exact duplicates of the first subform. I would really like to have multiple subfoms (I'm using tabs for information about contacts) on a single form. Please help.


I've never seen that happen, either you're doing something
funny to add the subforms or you've run into some kind of
bug.

I think you can fix things up by just changing the subfom
control's SourceObject property to the desired form object.
Be sure to set the Link Master/Child properties accordingly.
 
I tried both Steve and Marshall's ideas and then completely uninstalled and reinstalled Office XP Professional and Office XP Developer and the updates offered online (SP3) and tried again. It didn't work. The subforms still do not stay distinct. I'm open to more suggestions. Although I can't think what might be causing it my table structure, could there be something I should try to find in my table structures or my form structures themselves. Currently, I have given the same name to the linked fields in all the tables. Could that be causing my problem? Please advise. THANKS! :-)

--Catherine :-)
 
Cahterine,

Are you ending up with a separate subform placed on each page of the tab
control? What happens if you manually edit the Source Object property
of one of the subforms? Do you mean it somehow automatically reverts
back to what it was before, so that all of the subforms are the same as
each other? I can't see how the names of any fields, or any other
aspect of table structure or form design, could have any such effect,
but there is certainly something strange going on.
 
Steve
I have one tab control with two subforms, but all the other tab controls have one subform each. I have manually edited the source object property even to include [Forms]![frmContacts]![ContactID] as the master link and it still automatically reverts. It happens if I Save the form or close it and re-open it. "Do you mean it somehow automatically reverts
back to what it was before, so that all of the subforms are the same as each other?" Yes. This is exactly what is happening. It's becoming rather frustrating, really

--Catherin

----- Steve Schapel wrote: ----

Catherine

Are you ending up with a separate subform placed on each page of the tab
control? What happens if you manually edit the Source Object property
of one of the subforms? Do you mean it somehow automatically reverts
back to what it was before, so that all of the subforms are the same as
each other? I can't see how the names of any fields, or any other
aspect of table structure or form design, could have any such effect,
but there is certainly something strange going on
 
Catherine,

Would you be willing to let me have a look at this recalcitrant form?
If so, you can zip your mdb file (or an mdb into which you have imported
the relevant objects) and email to me... just remove the .ns from my
return email address. I will continue to use this thread to discuss
with you.
 
Cahterine,

I have checked out the database you sent me. I might as well confess
that I thought you must be doing something weird, but I now see that you
are telling the truth. I have no precise explanation, but it appears to
be some sort of corruption. I got the same bahaviour as you on the
existing frmContacts form. I then made a new form, based on your
tblContactDetails table, added a tab control, and put the 3 forms
frmClientCategory, frmClientSource, and frmContactDates, as subforms,
one to each of the pages of the tab control. Closed and saved the form,
opened it again, and sure enough, all 3 subforms had the same Source
Object, namely frmClientSource. But then, I made a new database, and
imported into it the tables and the 3 subform forms, and repeated the
above procedure, and eerything works correctly. Looks like you might
also need to do the same... import what you need, but not frmContacts,
into a new database, and re-build frmContacts. Sorry I can't be more
informative about what has led to this in the first place.
 
Thanks, Steve. It's nice to have someone else say I wasn't doing anything weird, I just have data corruption. I actually started doing exactly what you suggested on a different database before reading your response. Actually, instead of importing the tables, I was creating a new database from scratch referencing the original database's structure to recreate the tables. I haven't gotten to the form creation yet, but it seems you and I came to the same conclusion. I will try it all again (importing my tables instead of painstakingly recreating them) and let you know how it works. Thanks for giving it a second look for me. :-)
 
Steve
It worked. I have exported my tables and subforms to a new database and recreated my main form with all my subforms. It's all fixed now. Do you have any idea what may have caused the corruption to happen

--Catherine :-)
 
Catherine,

I am pleased to hear that everything is working well now.

My understanding about this type of stuff is very rudimentary. It has
nothing to do with your data itself, but instead is related to the
design elements of the form. It seems that sometimes, especially with
forms that have had a lot of design happening, e.g. controls added and
deleted and added again, and especially if you do certain things like
edit code when the VBE is in debug mode, or add controls with the same
names as deleted controls without closing and saving in between, and
stuff like that (he says vaguely), then there are "traces" (he says
vaguely again) of design definition information that get left behind and
result in Access getting confused.
 
Back
Top