Results 1 to 7 of 7
  1. #1
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118

    Wrong value in a Table from a combo box

    I have a combo box on a form whose record source is Table 1. The combo box pulls values from an Item table. The field selected in the combo box that I want to store in Table 1 is ItemCalories. However when I add the ItemCalories to a record the ItemID is what gets stored in Table 1, not the ItemCalories even thought ItemCalories is showing in the combo box. I cannot figure out how to get the ItemCalories stored in Table 1. DB attached
    Attached Files Attached Files

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Sorry, but IMHO you need to start again. Read up on DB design and relationships. I believe you need more tables e.g. MealTypes and FoodTypes
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by JonathanT View Post
    I have a combo box on a form whose record source is Table 1. The combo box pulls values from an Item table. The field selected in the combo box that I want to store in Table 1 is ItemCalories. However when I add the ItemCalories to a record the ItemID is what gets stored in Table 1, not the ItemCalories even thought ItemCalories is showing in the combo box. I cannot figure out how to get the ItemCalories stored in Table 1. DB attached
    Sounds like you have table lookups, which are not advised.
    You actually want the ID, then refer to that ID in the relevant table.

    EDit:
    Not withstanding Bob's comments, you have bound the incorrect field?
    I do not see how any of that form is actually meant to work?

    I do something similar for my diabetes, but I have one record per item per meal, and then I just sum the carbs. I do not store them?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Welshgasman View Post
    Sounds like you have table lookups, which are not advised.
    You actually want the ID, then refer to that ID in the relevant table.
    Hi Welshgasman. I thought the OP may have table lookups but I couldn't actually find any. However, as I stated in my earlier post the db design leaves much to be desired, IMHO.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    Go look at the combo properties, looks like it has 2 fields or more ItemID and ItemCalories and ItemID is the bound field although ItemCalories is the field showing. You do not need the ItemID field in the combo box if you want to just store the ItemCalorie value. So make the number of fields 1, remove the ItemID and remove the ItemID Length value. (or redo the combo box and only select the ItemCalories field.)

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Yes Bob, thay was my first thought, but I then downloaded the db, and it was a simple bound field problem.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    This DB was just to illustrate the problem. The DB I am working with had too much proprietary info to post here. The problem I had was an incorrect order in the query builder fields of the combo box and the wrong bound column. Thanks for all the replies. Problem solved.

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

Similar Threads

  1. Replies: 12
    Last Post: 10-03-2023, 05:36 PM
  2. Replies: 2
    Last Post: 10-16-2017, 06:47 PM
  3. Replies: 4
    Last Post: 11-25-2014, 11:23 AM
  4. Replies: 4
    Last Post: 09-04-2014, 07:00 AM
  5. Replies: 7
    Last Post: 05-21-2014, 02:55 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