Results 1 to 7 of 7
  1. #1
    howlettb is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    20

    Accessing field from previous form


    Hi, I'm working with a form (MainF) ... which has a subform (MainSubF). The subform has buttons that link you to other forms. When you click on one of those buttons, I have a control number that links the two forms by putting a CTR field into the linked form with a ctr defaul that = forms!mainf!ctr. My problem is that I'd like to use this subform on other forms. However, if I put the subform onto another form such as "MainTwo", none of the buttons on the subform will work because the path is now wrong. Is there a generic way to connect the buttons to whatever form the subform is attached to?? Any help you could be would be GREATLY appreciated! Thanks

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not really sure what you mean..... Are you trying to get the value from a control named "CTR" that is on the main form from the subform? If so, you could try
    = Me.Parent.CTR

  3. #3
    howlettb is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    20
    Quote Originally Posted by ssanfu View Post
    Not really sure what you mean..... Are you trying to get the value from a control named "CTR" that is on the main form from the subform? If so, you could try
    = Me.Parent.CTR
    Close ... I'm trying to get the CTR field from the MainF ... to a form that pops up when you click a button on a subform. The subform could be attached to several different main forms ... but they will all have the CTR field.

    I definitely think you're on the right track, but unfortunately, Me!Parent!ctr didn't work.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    You have SubForm1 on main forms "MainForm1", "FormMain2" and "MyForm3"? And each of the main forms have a control (not field) named "CTR"?

    You want to get the value from the control CTR on....??????

  5. #5
    howlettb is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    20
    Yeah ... I'm sorry for the confusion. I'm not a programmer. Currently, I have MainForm1....which has a field called CTR. Ctr is my link to everything. On the subform there is a series of buttons that lead to other forms. We'll call one of these forms "AdditionalForm". Currently, I have the CTR field on the AdditionalForm, with a default value of =forms!MainForm1!ctr. This puts that field into the additional form and keeps everything linked for me. Now, I'd like to add a MainForm2 and MainForm3. The subform on all of these forms could be the exact same, however, I can't figure out how to do the default on the Additional Form without actually stating the name of the Form (MainForm1, MainForm2, or MainForm3). Does this clear it up at all?? I could be going about this all wrong, but as I said, I'm not a programmer, yet I have this database doing some pretty complicated stuff. Thanks Steve for your patience.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK, let me tell you a story..

    Normally (and I use that term loosely) You have Table1 with field T1_ID_PK as an autonumber (PK), plus additional fields. And you have Table2 with T2_ID_PK as autonumber (PK), T1_ID_FK as Long, plus other fields. The two tables are linked (related) by fields T1_ID and T1_ID_FK.

    The two autonumber fields have no meaning (for people) - they are unique field used to relate two tables. So you can see that Table1 is the "one" table and Table2 is the "many" table.

    MainForm1's record source is a query, "Query1", based on Table1. All fields are in Query1.
    Subform1's record source is "Query2", based on Table2. Again, all field are in the query.

    When you drag (add) SubForm1 to MainForm1, usually the wizard pops up a dialog box and asks what fields are the relating fields. You would select the field T1_ID_PK from the master table and T1_ID_FK field from the child table.

    Anytime you change records in the main form, the sub-form records automatically change to match the PK / FK relationship. If you add a record to the sub-form, the FK field value in the sub-form is set to the master form linking field.

    And all lived a happy, related life. The end..... Except for adding more forms, queries and reports.

    One other point on terminology:
    Tables (queries) have fields.
    Forms have controls.
    Controls are bound or unbound.
    If a control is bound, that means it is tied to a field from the forms's recordsource.


    How close it this to what you have??
    Is the recordsource for "AdditionalForm" ths same as "MainForm1"?
    Do you have to have many "Mainforms"? Couldn't you use a tab control and have additional subforms on the tabs?

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

Similar Threads

  1. Replies: 18
    Last Post: 10-25-2012, 10:57 PM
  2. need to check a field for previous record in form
    By clemdawg in forum Programming
    Replies: 1
    Last Post: 06-13-2012, 07:17 PM
  3. Replies: 15
    Last Post: 05-24-2012, 02:36 AM
  4. Replies: 2
    Last Post: 07-14-2011, 09:23 AM
  5. Make new field based on previous field's answer
    By VictoriaAlbert in forum Access
    Replies: 1
    Last Post: 04-11-2011, 09:54 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