12

I am new to access (I have only 2003 version) and I am getting crazy. Consider also that I am a novice with DB in general, so now I am at the point that I am very confused... please help. I am trying to design a database to catalogue all the books I have. I created the tables and set the relationships Image of my DB ; I have a few tables related to the “Books” one in Many-to-Many relationship (e.g. Authors: each book can have multiple authors and each author can “have” multiple books) and a few others in a simple One-To-Many (e.g. book type: one book can be of one type only, but there can be many book of that type. Now I would like to create a single form (with sub-forms if needed) to populate my tables. I would like to be able to add a new book and select from, for examples, existing authors or add the author anew; same for data in the One-to-Many relationship.

How can I do this?

I am really lost, do I need multiple forms and to add them as sub forms of a main one, do I need queries, or what?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
rodedo
  • 791
  • 4
  • 10
  • 23

1 Answers1

20

The above design requires four subforms. Each subform should be based on the junction table with book id as the link child and master field and a combo box based on the relevant table for the second table id.

For example, your first subform is Authors, the table it is based on is Libri_Autori

Link Master Field: Id
Link Child Field: SchedaLibro

Combobox:

Control Source: SchedaAutore
Row Source : SELECT Id, Nome FROM Autori
Bound Column: 1
Column Count : 2
Column Widths : 0, 2

Create your book form and then start adding subforms, the wizards will do most of the work for you.

To add records to the authors table, you need to set Limit To List to Yes and run code on the Not In List event. I like to use a small pop-out form to add items to the "back ground" tables. This may be easier with Access 2010, because you can set a ListItemsEditForm


1, The book form, just before adding the subform. Note that Use Control Wizards is selected. This is the default, so unless you unselected it, it should be fine.

Step 1 Using a wizard

The various wizard steps for adding a subform Wizard steps for adding a subform

Selecting the subform fields

Selecting the subform fields

Selecting the link child and master fields

Selecting the link child and master fields

The form showing the subform control highlighted in yellow and the control properties

Subfrom control

2, Adding the combo

You can either change the field added by the subform wizard to a combo by right clicking and setting the properties yourself ...

Right-click for change to combo

... or you can delete the existing control and add a combo using the wizard. The first step is to choose the type of combo.

Step 1 combo type

The second step is to choose the table or query

Step 2 choose table or query

Step three is to choose the fields

Step 3 choose fields

Step four chooses the sort order and is not displayed here, this is step five, which is to set the column widths

Step 4 skipped, step 5 set column widths

Step six is to set the Control Source

Step 6 set Control Source

You will end up with a combobox with the properties illustrated

Subform combo and properties

Final form

Final form

Fionnuala
  • 90,370
  • 7
  • 114
  • 152
  • Thanks!. Indeed it is not all clear to me, as said I am a novice, but I will work on your suggestions and come back for more questions. – rodedo Aug 27 '12 at 07:45
  • Look at the Northwind sample database ( http://support.microsoft.com/kb/824265 ) to see how these ideas work. The Order form shows how some of the ideas work together. However, only use Northwind for a very rough guide, the code in particular is not the best. – Fionnuala Aug 27 '12 at 10:02
  • Hummm... is there some step-2-step tutorial online? I believe I still miss some basic steps; how do I create the subform based on Libri_Autori, wizard? how do I define the "Link master/child field"? and where do I define the Combobox? So far I added it in the LookUp tab in the Table Design View for table Libri_Autori and field SchedaAutore, is this what you meant? – rodedo Aug 28 '12 at 12:39
  • Absolutely not! Do not put look-ups in tables unless you are using the database on Sharepoint. – Fionnuala Aug 28 '12 at 12:45
  • Thanks for the effort and time! – rodedo Aug 28 '12 at 16:19
  • I also found this website that seems to have many answers to my questions; adding it here for everybody's benefit: [link](http://www.techonthenet.com/) – rodedo Aug 31 '12 at 11:10
  • I was having lot of trouble in figuring out how to find data on a form displaying data from multiple data sources. Is there a tutorial I could follow to help me figure out a solution for this. – skadoosh Sep 14 '16 at 21:45