Results 1 to 5 of 5
  1. #1
    ribbs2521 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    3

    Enter data into a table with data from a form showing two tables

    I have three tables;



    Foods: ID, UPC, description, brand, (various nutritional details)
    Recipes: ID, Recipe_Name, Description
    Recipe_Ingredients: Recipe_ID, Food_ID, quantity, uom

    I have a main form which shows the Recipe and is only tied to the Recipes table, then a sub form that shows the ingredients. The ingredients form is based on the Foods and Recipe_Ingredients tables WHERE Recipe_Ingredients.Recipe_ID=Recipes.ID.

    I would like to be able to enter data into the ingredients sub form and have it create a new record in the Recipe_Ingredients table but for some reason it keeps giving me an error because the Food_ID field is not getting populated.

    I have a combo box allowing the user to select a food based on the Foods.description field. Would I have to write some VBA to input the Food_ID field from the data related to this combo box or is there a property somewhere that allows for that? Basically I want my combo box that shows Foods.description to enter Foods.ID into the Recipe_Ingredients.Food_ID field.

    Sorry if this is overly confusing. The problem is I can make it work by attaching a macro to that combo box but I'm not an advanced Access user so I'm not sure if there is some simple feature already built in for this sort of thing. Please let me know if you need further clarification or some SQL code.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you using the LinkMaster/ChildFields of the SubFormControl?

  3. #3
    ribbs2521 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    3
    I have no idea what those fields are are so I will definitely investigate that so I am apprised of that feature.

  4. #4
    ribbs2521 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    3
    Okay, I looked up some information and now I understand what these fields do. It looks like access automatically created the connection for these fields when I created the form. The problem I have isn't with the main form linking with the sub form, that's okay. When I add a new ingredient the Recipe_Ingredients.Recipes_ID field is filled in from the parent form data but the Food_ID field is not.

    I guess, to try to clarify further, if I already have an ingredient in the recipe, say it's a Bagel and it has an ID 1234, if I change Bagel to anything else, the Food_ID field is not updated. I need the Ingredient combo box to drop down with selections from Foods.Description but fill in the Recipe_Ingredients.Food_ID when the new record is added.

    As I said, I can make this work by assigning a macro when the selection is changed but I wasn't sure this was the correct thing to do or maybe I am on the right track and it is the proper way to handle this situation. I am just trying to do things the right way now, rather than just getting it to work whichever way I know how.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The LinkMaster/ChildFields can contain more than one field separated by a ";". Does that help?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-03-2012, 12:28 PM
  2. How to enter data 'ranges' in tables ...?
    By Captain Database ...!! in forum Access
    Replies: 20
    Last Post: 07-18-2011, 10:18 AM
  3. Enter Data into a Junction Table
    By darkwan75 in forum Database Design
    Replies: 3
    Last Post: 04-13-2011, 08:55 PM
  4. Replies: 3
    Last Post: 02-08-2010, 09:00 AM
  5. Adding a table cannot enter data
    By tak4 in forum Queries
    Replies: 0
    Last Post: 02-03-2009, 10:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums