Results 1 to 4 of 4
  1. #1
    noretoc is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    18

    fill subform field based on main form value

    This is probably another easy one, but I am having trouble with it. I have a main form (main) and a subform called items, each using a table of the same name as the source. The main form has a field called name. The subfom has a field called settlement. These are the fields linked to control which values from the table items are shown. The items subform is editable. I want to be able to enter a record in that subform, and have the settlement field on the table for that record automatically update to the name value of the current record on the main form. This way when i step out of that record on the main form and go back, it is going to pull any items that i entered into the subform previously.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    A main form and a subform should not be bound to the same table. This makes no sense.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    noretoc is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    18
    I was unclear on that. Actually let me rephrase the whole question, as I think I was trying to get the form to do something it should be doing alread. I'll attach a copy of the DB.

    The form called main, has a tab control on it. On one tab is a sub form called NPC, the other tab is a subform called cityitem. Each of these subforms are linked to tables with the same name as the subform. Each of the tables is joined to the settlement table (Which the main form is based off of.) The field "name" in the main table (settlements) and on the main form is joind to the field "Settlement" on each of the subforms.

    What I believe should happen, is when I enter a record in the subform cityitem, the "settlment" field should automatically reflect the same value as the "name" field in the current record of the main form. This links that record in the subform to the record in the main main form, so when I go back to this record, is shows any items that I entered. This is not happening on either of the subforms. instead the "Settlement" field displays Main (the name on the main form). It does not update to reflect the value in the "name" Field on the Main form.

    When I fisr made the subform NPC, it was working as expected. If I entered a record on the NPC subform, the "settlement" field on that form automatically filled with the "name" on the main form. This connection has somehow broke though and I can't seem to get it back. I have checked the Master Field and Child Field on both subforms and they both are correct. I also checked the relationship on the underlying tables, and that seems to be fine. I am at a loss, but am probably missing simething simple.
    Last edited by noretoc; 01-17-2012 at 11:55 AM. Reason: fixing spelling and grammar

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Problem is Name is a reserved word in VBA/Access. Should not use spaces, special characters, punctuation (underscore is exception) in names nor reserved words as names. If do, must enclose in []. Set the MasterLink to [Name]. Wait, that seemed to work for a minute. I suggest best fix is to rename the field in Settlement. The name change should pass into the queries and MasterLink properties. Will have to manually change the ChildLink on the Totals subform.

    The 3 Magic tables should be 1 table with another field for MagicClass (major, medium, minor).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-11-2011, 10:02 AM
  2. Fill in form header based on subform
    By VictoriaAlbert in forum Forms
    Replies: 1
    Last Post: 04-21-2011, 01:38 PM
  3. Subform Combobox based on Main form combo box
    By accessmom in forum Forms
    Replies: 5
    Last Post: 02-21-2011, 07:02 AM
  4. Subform Filter based on Main Form Information
    By james.carpenter2 in forum Forms
    Replies: 0
    Last Post: 02-16-2011, 09:55 PM
  5. Replies: 1
    Last Post: 11-16-2010, 08:42 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