Problem with programatically changing subform properties

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #16
    Did Don's suggestion of manually setting the Form.RecordSour ce after the .SourceObject and then .Requery not work for you?

    Comment

    • Denburt
      Recognized Expert Top Contributor
      • Mar 2007
      • 1356

      #17
      Oh and looking this over again are you sure that when you set your query to retrieve the values from the listbox that you are designating quotes for text and no quotes for numbers # for dates etc.?

      Comment

      • postman
        New Member
        • Nov 2008
        • 63

        #18
        Sorry, I'm just getting opportunity to get back to this project today....
        Don, I will try your suggestion now and post the results soon.

        Thank you for all your assistance. It is much appreciated!

        Comment

        • postman
          New Member
          • Nov 2008
          • 63

          #19
          Solved!

          It's working now...using the original setup I had (see post #4). In the course of implementing Don's solution, I found the root problem:
          If both the subform and the parent form's recordsources are pulling data from their respective tables including "ID" fields that are named the same, the subform will not display data.
          NOTE: This only happens when programatically switching the subform control's "Sourceobje ct".

          Here are the details....

          The 3 tables all have an ID field with the same name "ID" (it's an autonumber field & Primary key on all 3 tables). We'll call them "ParentForm_Tbl ", "FormA_Tbl" , "FormB_Tbl" .

          The Parent form's recordsource was set to the table "ParentForm_Tbl ".

          The Query for the subform's recordsource pulls data from "FormA_Tbl" (or "B"). I had the "ID" field as the criteria (WHERE statement), but also included in the SELECT statement as a field to retrieve data from. I removed it from the SELECT statement, then all worked fine!

          So I did some more testing and put it back into the SELECT statement, but renamed the "ID" field in the Subform table to something different (e.g. "IDformA") than the ID field in the Parentform table. It also worked fine!

          I don't know why this is happening. I tried recreating the problem by renaming other fields to have the same name in both the Parentform table and Subform tables, but did not have any problem. Maybe it has something to do with the ID fields all being Primary keys.

          So, this issue appears solved. I don't understand the problem, but it's kind of a moot point now, I guess.

          Thanks again for all your assistance. I'm sure I would not have found the solution without your help!

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #20
            Wow!

            Nice post Postie :)

            It's great to have such a complicated situation properly answered.

            Comment

            Working...