What subform Access makes by default (1 Viewer)

got_access:]

Registered User.
Local time
Today, 02:39
Joined
Jun 15, 2018
Messages
83
Hi,
I know there are different ways to make a combination MAIN/SUB form for a one-to-many relationship.

One way is to create the subform perhaps in datasheet or tabular mode and then use the sub-form control to import it into the main form. With this method one ends up with the sub-form as a unique object which is then visible in the navigation pane. And because of that - I personally don't consider this the best approach.

Another way is to create the main form and use a LIST box control - where the record source for that list is an SQL statement. And as one would do with the sub-form, locate this list form nested inside the main form. This method does not create the sub-form as a unique object visible in the navigation pane. But it has the disadvantage of requiring the developer fuss over its appearance - especially if one prefers Access' standard datasheet view.

A third - and perhaps the simplest way - is to allow the Access wizard to create the Main & Sub Form from two tables having a one-to-many relationship.
Highlight the "parent" table in the navigation pain, and then simply click Create\Form.
Access will create both forms and nest the sub-form inside the main form.

My question is about the subform that is created in this last method. This sub-form's parameters are automatically set to display it in the standard Datasheet view with headers. The wizard gives it a default name of "Child##". And the wizard does not create it as a unique object visible in the navigation pane.

It would almost seem that this method would be the most popular. As you don't end up with the subform as a unique object in the navigation pane. And yet the wizard creates it to appear as much in datasheet view as if it were a unique form object.

Can anyone point me to information about these various subforms and what the difference is between them? Is there a general preference that most developers have for how they create these? It would seem to me that not having a subform appear as a unique object in the navigation pane would be generally preferred. And having the sub-form look/feel be that of Access' standard datasheet view would also be preferred. But that's just me.

Sincere thanks in advance!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:39
Joined
Oct 29, 2018
Messages
21,454
Hi. Actually, I personally prefer the first one. I create a form object I intend to use as a subform to a parent form. I haven't tried using the Wizard that way, but I suspect it's probably using the table or a query rather than a form to display in the subform control, which you can also do yourself. Using a Listbox is technically not a subform.
 

Mark_

Longboard on the internet
Local time
Today, 02:39
Joined
Sep 12, 2017
Messages
2,111
I also create subforms as unique forms. This allows me to set up any formatting/data validation/what not that I need without having to jump through a lot of hoops.

I also normally don't leave the navigation pane open for users to look at. Rather I have a form that calls other forms/reports.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:39
Joined
Sep 12, 2006
Messages
15,638
the best way is to try it out, make sure you understand the methods, and use your own choice. personally, I create the subform as a form, and then show it in a relevant section of the main form. (as a linked subform)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:39
Joined
Jul 9, 2003
Messages
16,271
I usually create a sub-form as I described in the video on my Website here:- Sub-Forms See the section titled:- "Adding Hobbies to a Student Database"

One of the most important things to realise about subforms is that the subform is not actually on your form. The action of adding a form to another form to become a sub-form creates a new control which is an intermediary control between your main form and the subform. This intermediary control surrounds the subform. It's called a subform subreport control. I refer to it as a "subform window". Unfortunately, MS Access gives it a default name, the same as the subform contained within it! This can be confusing if you don't know! I change the default name created by MS Access to a name following my own personal naming convention for example subFrmWinFORM_NAME where the prefix "subFrmWin" can be read as sub-form window...


I suspect you already know this, however I thought it worth posting:-

Create a form that contains a subform (a one-to-many form)

It's a excellent article by Microsoft on subforms and will prove valuable for anybody else who happens upon this thread.
 

got_access:]

Registered User.
Local time
Today, 02:39
Joined
Jun 15, 2018
Messages
83
One of the most important things to realise about subforms is that the subform is not actually on your form.

Thank you everyone for your responses!

I actually didn't know that the subform is not actually on the form. I suspected it was perhaps an instantiated copy. But then if one deletes that subform within the navigation pane - it is lost to the main form. So that would make perfect sense. So the control in the main form control must be functioning as a place-holder, pointer, or link to the actual form.

But I'm guessing that is not the case when one uses the Access wizard CREATE\FORM method.

Thanks also for the link!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:39
Joined
Oct 29, 2018
Messages
21,454
But I'm guessing that is not the case when one uses the Access wizard CREATE\FORM method.
Actually, it should be the same. Like I said earlier, I haven't tried to use the Wizard, but if it's using a table or a query instead of a form, then deleting said table or query would also break the form/subform like it would for a regular form.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:39
Joined
May 21, 2018
Messages
8,525
It would seem to me that not having a subform appear as a unique object in the navigation pane would be generally preferred.
No way, I would rarely or never do that. Even if I want a datasheet view in the subform, which I rarely do, I want a source object to put code against. I rarely would have a subform without any code. Datasheets have a lot of native functionality, but I can code a much better tabular subform.
 

Users who are viewing this thread

Top Bottom