Results 1 to 6 of 6
  1. #1
    DarrenReeder is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    9

    New to programming in MS access 2007...

    Hello, i am new to progrmaming in MS access 2007 although i have some basic programming in C++, Java, Pawn and some web design languages (PHP, xHTML, CSS, Javascript).

    for my database i need to make it so that when i enter the Product Name from a dropdown menu it gets the product ID from another table.. (so, I choose product name "shoe" then it queries the "qry_Products" table for the product with the name as "shoe" and then gets the ID.."PA01" for example... and puts it into the Product_ID in the original table where i chose the name from the drop down menu... )



    Im pretty sure i need programming in access to do this or maybe even macros?... Ive already made a query which can do this for all my records although i have to run it manually and this causes problems..

    -thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You shouldn't need code. You can include both fields in the combo box row source. It's fairly common to have the combo display the name but actually save the ID.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    DarrenReeder is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    9
    So , would it be better to have the dropdown box to say "shoe" for example but then change that field to the foreign key?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Generally speaking when working with related tables, you save the key value. In this situation, you might have a products table with info about products and a sales table with info about each sale. In the sales table, you would only store the product ID, not its name. In that situation, a combo might have both ID and name in the row source, with ID hidden but the bound column. That means the user will see the name, but the ID is what gets saved to the sales table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    DarrenReeder is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    9
    So, it will say "shoe" in the drop down menu but once it is selected it will say "PA01" ?? (for example)...

    OR would you still see the word "shoe" on that field?? i understand what your saying and it sounds like its what i need to do for normalization..

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The user will always see "shoe" in that scenario, but that's just one way to do it. You could display both to the user while the combo is dropped down, and either one of the values when it isn't. It depends on your specific needs.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 0
    Last Post: 11-17-2009, 02:35 PM
  2. New to Access programming
    By pushpm in forum Programming
    Replies: 1
    Last Post: 02-20-2009, 03:03 PM
  3. Access 2000 programming startup options
    By nosaj_ccfc in forum Programming
    Replies: 2
    Last Post: 10-17-2008, 02:18 PM
  4. Programming Language like Access
    By cwf in forum Programming
    Replies: 2
    Last Post: 05-17-2008, 03:02 AM
  5. Access Programming and Access Data Page
    By frmdread67 in forum Programming
    Replies: 0
    Last Post: 03-19-2008, 03:11 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