0

I am new to access and trying to create a simple form with a subform. The database has the relationship set. When I select an ID from the combo box linked to the subform, the subform pulls the records with the correct foreign key. However, when I try and add new records, I can't seem to get the foreign key to set with the ID from the combo box. From what I understand it should just save the fk automatically, but nothing I try seems to get it to grab the ID. Here is the link to the simple database so far. Any specific sections that are of interest I can add.

Thanks!

Naing Lin Aung
  • 3,373
  • 4
  • 31
  • 48
Ash
  • 1
  • 3
  • Your approach is incorrect. This thread might help you on your way: [MS Access Creating a New Order And Orderline](https://stackoverflow.com/questions/29800907/ms-access-creating-a-new-order-and-orderline) – Rene Jun 03 '19 at 00:03
  • I don't get where my approach is different from the answer linked. The table structure is almost the identicale, with the fk relationship set, and the child/parent fields bound – Ash Jun 03 '19 at 03:56
  • Did you read the part about form and subform and how to link both of them? You should place your subform within your main form. – Rene Jun 03 '19 at 04:26
  • Is my subform not in my form? The subform has been linked to the master field ID Control, a combo box on the main form, and the child field linked to order ID, the column housing the foreign key – Ash Jun 03 '19 at 04:46

1 Answers1

0

Don't know how you created the subform, but if you remove the subform and then drag-and-drop the query on the parent form, a new subform is created, and the wizard asks you by default:

Show Order Items for each record in Order by ID

Leave that selected, click next and continue, and your subform now works as expected.

Gustav
  • 53,498
  • 7
  • 29
  • 55
  • Dragging and dropping the query did not result in a wizard. Recreating the subform still results in the correct Order Items being displayed on the form, but new records are not created with the asociated ID, the Order ID foreign key is always 0 when adding a new record – Ash Jun 03 '19 at 18:47
  • Can't tell, as it works here and always has. Try a reinstall of Access. – Gustav Jun 03 '19 at 20:07