Results 1 to 7 of 7
  1. #1
    swalsh84 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    36

    Add Items from Form to table

    I attached my database to the thread. It should be self explanatory, but basically I have a drink name and a combobox of ingredients. I want to be able to navigate through the records and add ingredients to specific drinks. Right now I'm stuck on how to add the items from the form. There are both "Add" and "Delete" ingredient buttons that are available. I'm stuck on the syntax. Thanks in advance.

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    try this out.

  3. #3
    Join Date
    May 2010
    Posts
    339
    This seems like a classic 1:M one drink name many ingredients? The original model doesn't seem very flexible. See attachment. Also you could add combo boxes to the fields in the subform.

  4. #4
    swalsh84 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    36

    Closer...

    The reason I set up the original with three tables is so that later down the road, I can look in the pantry or fridge and ask the database what I can make with the available ingredients. In your model, it doesn't look like you can query the database in this way. I'd rather have an indexed table in the middle of the drinks and ingredients so that I can query that way.

    Make sense? I was hoping to get some VBA in my add and delete buttons to add a record in the middle table that included the drinkID and ingredientID.

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    here i see you have three tables Drink, Ingredients and List. TheShabaz exmaple allows you to select a drink and add ingredients to it the data is inserted in the table list. now you are saying the you want to query your records. I have some questions
    1) Have to tried out The Shabaz's example.
    2) Does it do what you want.
    3) If No what do you want
    4) if yes what more do you want.

    how would you like to query your records.

  6. #6
    swalsh84 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    36

    Hope this clarifies

    1) Yes I did try the example.
    2) It does not do what I want.
    3) As stated in my previous reply, I would like to be able to query the records. TheShabaz example is simple and would work, but I want to be able to query records based on selection of a few ingredients. So later down the road I could have a form with some combo boxes. I could select 2-3 ingredients that I currently have at the house and determine what I could make with said ingredients. By keeping the ingredients table separate from the drinks table it makes this possible. When they are combined as in TheShabaz example you don't have this flexibility.

    As well, I think I mentioned VBA script for the Add and Delete buttons. This was the original request. Basically I want the "Add" button to add a record in theList for each ingredient addedd to a drink. In psuedocode form:

    Code:
    insert into theList where drinkID = drinkIDFromForm and ingredientID = ingredientIDFromForm
    I don't know how to reference the combo box on my current form so that I can write a sql statement to do the above.

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Regarding referencing combos:

    here is an example:

    Dim strSQL as String

    strSQL="Insert Into Table1 (Employee_ID,Employee_Name) Values(" & Me.Combo1 & ",'" & Me.Text1 & "');"

    Here Combo1 Gives me the Employee_ID and Text1 Gives me the Name. Strings has to be i ''.

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

Similar Threads

  1. Query Not Listing All Items
    By Rawb in forum Queries
    Replies: 7
    Last Post: 05-14-2010, 08:00 AM
  2. Remove items from Tabular Form
    By JoshS in forum Forms
    Replies: 3
    Last Post: 04-26-2010, 02:18 PM
  3. Highlighting Items in List Box from Table Data
    By swalsh84 in forum Programming
    Replies: 2
    Last Post: 01-25-2010, 08:55 AM
  4. list box items
    By thewabit in forum Forms
    Replies: 12
    Last Post: 01-01-2010, 08:59 PM
  5. Added items in a column.
    By Wrangler in forum Forms
    Replies: 3
    Last Post: 03-25-2006, 07:56 PM

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