Results 1 to 8 of 8
  1. #1
    MyWebdots is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    8

    Autofill of a field based on another

    Hi there,


    I am a newbie and have written a database (access 2007) for plant management. I would most appreciate help to what I think is a very basic problem! I am really stuck on autfilling a field.

    Topline: When I pick the Plant Scientific Name on my form, I want it to auto populate the Common Name.

    Plant names are in TABLE one...(this also has a primary key)
    Plant Scientific Name
    Plant Common Name

    TABLE two also has a bunch of other data, (this table includes two fields for the plants above as a lookup to that other table)
    Date recorded
    Place found
    Co-ordinates.

    I have created a form with all fields. Including the Plant ones as a lookup.

    What do I need to do so when I pick my Plant Scientific Name - it auto fills my Plant Common Name?

    Thanks so much in advance.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Base your form on a query that joins the two tables.

  3. #3
    MyWebdots is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    8

    Autofill of a field based on another

    thanks ruralguy - - not sure what you are saying - a query to do what exactly...sorry for my noobness?

    Currently My 1st database has:

    Weed number (primary key)
    Plant name scientific (lookup from table 2)
    Plant Name common (lookup from table 2)
    Field 4
    Field 5
    Field 6

    2nd database has

    number (primary key)
    Plant name scientific (look up from table 2)
    Plant Name common

    My form has all the fields in Table 1.
    Every time I pick either the 'plant name scientific' - I want the matching 'plant name common' to come up (these always match and never change). Vice Verse if I pick the 'plant name common' I want 'plant name scientific' to come up.

    (the reason for this is when the scientists are in the field they sometime's know the plant name, and sometimes know the scientific name).

    I have a feeling it may have something to do with the primary key -
    Can I do this through a wizard or do I need to write some VBA code? If so - could someone help me? Many thanks!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    To start, you do not want to use LookUp Fields. All you need in the first table (not database) is the primary key from the other table (not database) as a ForeignKey. Use a ComboBox Control on your form for each look up you need: one for the scientific name and one for the common name. You can use code in the after update event of each ComboBox to set the ForeighKey field.

  5. #5
    MyWebdots is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    8
    Ruralguy - thankyou. That is starting to make sense. I now created a FK in my table. (and removed the lookups).

    (see my newbieness calling tables 'databases!).

    Can you please provide me the code in the after update for one of the combo boxes - and I will try the other?

    Most apprecicated.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use the ComboBox wizard to place one of the ComboBoxes on your form. Select the option to look up a value in another table.

  7. #7
    MyWebdots is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    8
    Hi there - thanks for responding.

    I have done all that - still just don't know the 'afterupdate' code!

    Thanks

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    [ForeignKeyField] = Me.ComboBoxName.Column(0)
    ...using your field and control names of course.

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

Similar Threads

  1. Updting a field based on another field
    By laotzu in forum Access
    Replies: 7
    Last Post: 04-26-2010, 07:47 AM
  2. Autofill form fields based on another field
    By ljs1277 in forum Access
    Replies: 3
    Last Post: 02-16-2010, 02:51 PM
  3. Lock Field based on other field value
    By diane802 in forum Access
    Replies: 5
    Last Post: 01-14-2010, 10:40 AM
  4. Autofill field based on autonumber field
    By frevilla in forum Forms
    Replies: 1
    Last Post: 09-11-2009, 02:50 AM
  5. Total based on Formula based on field value
    By cjbuechler in forum Reports
    Replies: 15
    Last Post: 07-10-2009, 09:56 AM

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