Results 1 to 4 of 4
  1. #1
    tim.cassey is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    25

    Populating field in subform from field in form

    Hi there,

    I have a form with subform in it, and I am currently trying to make it so that when a user picks a name from a dropdown box in the main form, it populates the name field in the first box within the subform.

    I have been able to successfully code this, but instead of showing a name in the subform, it shows its associated ID (primary key). Would anyone know how to fix this?

    This is the current code I am using on the 'after update' portion of the name text box in the main form:

    [Forms]![WOMAIN]![WOSUBMAIN1 subform].Form![TechTest] = Me.Tech_Test.Value

    'TechTest' is the field in the subform that I want to update, whilst 'me.tech_test.value' refers to the field on the main form.

    Any help is appreciated!

  2. #2
    tim.cassey is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    25
    I quickly figured this out by changing the '.value' to '.text' on the end of the Me.Tech_Test part of the code.

    What I would like to figure out is, in the subform the user has the ability to add multiple lines (table format). How do I make it so that the name only populates in the first line, with any additional lines allowing the user to enter in / select a different name?

    The reason for this is that whilst one main person may be entering data in the main form, many people could be involved in the subform.

  3. #3
    tim.cassey is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    25
    So I need to revert back so that each time a new line is added into the subform, it comes up with the name originally placed in the main form... changing the coding to add .text onto the end caused an error on subsequent lines of the subform, and going back to just .value still shows the primary key / unique ID... does anyone know how to fix this? For other fields that are populating automatically the correct data shows up?

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    In cases like this, always specify what event you're using. A combo's text property is what's visible in the control and is not necessarily what the control actually is holding. The difference between the two can be useful, but also prone to error. Value is the default property for a combo or textbox, so you don't even need to use the word in code.

    My guess is that you're using an event that grabs the info before the control is updated (hint: use the AfterUpdate event); maybe BeforeUpdate? Another thing that can cause this is having two or more columns in a combo (regardless of how many are actually visible) and setting the bound column property to the wrong column. Often a novice programmer hides the first column, shows the user the second & third & etc. (which is acceptable) but forgets to change the bound column to one of the other visible ones that is needed. The first one is often the record ID and isn't the value they want to use to populate some textbox.

    This is the current code I am using on the 'after update' portion of the name text box in the main form...
    Don't understand how this comes into play unless you're expecting the combo box to put something in the control and think that this will cause the AfterUpdate on the textbox to fire, because it will not. You will have to leave or save the record, or move the focus off of it - anything that causes it to update.

    the ability to add multiple lines (table format)
    This is an atypical use of words to describe your form. I think you mean datasheet, or maybe continuous form?
    You have a few issues that maybe warrant breaking up into threads to make the answers easier for everyone to follow. See what you can fix with this information, and we'll see after that.
    Last edited by Micron; 04-20-2016 at 10:00 PM. Reason: grammar
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. populating field in form based on input field
    By BrandonFinn in forum Forms
    Replies: 7
    Last Post: 10-30-2014, 10:45 AM
  2. Replies: 4
    Last Post: 07-28-2013, 12:40 AM
  3. Replies: 5
    Last Post: 11-16-2011, 07:30 PM
  4. Replies: 2
    Last Post: 09-28-2011, 02:41 AM
  5. Auto Populating Field in Subform
    By sparlaman in forum Forms
    Replies: 21
    Last Post: 03-28-2011, 12:58 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