Results 1 to 8 of 8
  1. #1
    manicminer is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    8

    Populating a field

    A completly newbie question, I know.

    Say I have a table "product" with fields "serial" and "company"
    I have a an unbound form, where in one listbox I can choose from all the "serial" values.


    Now, after i choose the "serial" from the listbox, I would like to display the value "company" in a textbox (from the currently selected record).

    Should be trivial, but it eludes me....

  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,641
    Does this help?

    BaldyWeb - Autofill
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mholland999 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    6
    Use the Dlookup function

    dlookup("[Company]","Product","[serial]='" & <me.yourformfieldname.value & "'")

    you can assign the value of an unbound control to a the dlookup function. you might have to write a bit of code on the afterupdate event or the onchange event to update your calculation

    Sub onchange()
    me.yourformfieldname.requery
    End sub

  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,641
    It would work, but why make a second trip to the data when the listbox already has it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    manicminer is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    8
    Thanks everybody, but I cant somehow figure it out. Maybe I didn't specify the problem correctly.
    So.... the table stands as before. "Serial" is the primary key btw.
    The form contains only two fields. A combo box and a text field.
    In the Combo box, I can choose from all the "serial" values from the table.
    After the "serial" is selected, I need the textbox to dispay the value of the company field associated with it.

    Unfortunately any varions in the "after update" property of the combo box doesnt yield right results :-(

  6. #6
    manicminer is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    8
    Figured it out, finally. Thanks to kicking me in the right direction ! :-))))

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Glad you got it sorted out. I was sound asleep!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    mholland999 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    6
    manicminer you should post your solution for other readers.

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

Similar Threads

  1. Populating one field based on another
    By thedanch in forum Access
    Replies: 1
    Last Post: 06-11-2012, 11:13 AM
  2. Populating a field from another table using DLookup
    By Jamescdawson in forum Access
    Replies: 22
    Last Post: 03-16-2012, 09:59 AM
  3. Replies: 3
    Last Post: 07-14-2011, 05:33 PM
  4. populating value of one field to another
    By jzacharias in forum Database Design
    Replies: 2
    Last Post: 09-08-2010, 02:39 PM
  5. Auto Populating a field in a table
    By softspoken in forum Access
    Replies: 11
    Last Post: 04-05-2010, 02:52 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