How do I link a tab control subform to the mainform that is unbound?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Equus57
    New Member
    • Oct 2014
    • 4

    How do I link a tab control subform to the mainform that is unbound?

    I have a mainfom that uses a stored procedure with parameters as the recordsource, but is not bound (recordsource property is blank). In the mainform I wrote code to indicate the record source is equal to the stored procedure & the parameter. On its own, it runs fine. I inserted a tab control with 3 tabs and each has it's own sql view based record source. When I did this, the autolinking didn't occur. I manually assigned the master an child links. When I view the form, it says it can find the the master field used in the link. If I assign the mainform's record source on the property sheet, I get prompted both by the procedure and the form to enter the parameter. I can't figure out what the problem is since I have done this with other forms, just not a tab control with a form. Can someone please help?
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    Equus,

    I am a little confused by your post, but I think I kinda understand what your problem is.

    First, I'm not sure what you mean by
    I have a mainfom that uses a stored procedure with parameters as the recordsource
    as a procedure is not a set of records that can be used as a record source. However, if what you mean is that you have a stored query (which uses parameters for its criteria), then that makes sense. You have just designed the Form so that it is not bound to that record source at start up. This I understand.

    Second, I don't understand
    I inserted a tab control with 3 tabs and each has it's own sql view based record source
    Tab Controls do not have record sources--nor do any of the separate tabs on tab controls. However, if you mean that you inserted a Tab Control with three tabs and each tab has its own subform embedded in the Tab, then I understand that.

    You state
    When I did this, the autolinking didn't occur
    This auto-linking did not occur because your main form is not bound. Had the main form had a record source, when you embedded the subforms (this is my assumption here) Access would have tried to find fields within each record source that properly correspond to each other.

    Also, the reason you cannot do this manually, at this time, is, again, because the Form is not bound to a Record Source. If your Form were bound during the design, and you make these Master-Child relationships, you can delete the Record Source and then when the Form opens at run time, when you assign a new record source, the same Master-Child Relationships will be maintained (as long as the corresponding field names are included in the record sources.

    I think this might help to explain what is happening, but I would need more information to trouble shoot.

    Please take some time to describe in a little better details exactly what you have done and how you have constructed your Form.

    Comment

    • Equus57
      New Member
      • Oct 2014
      • 4

      #3
      Linking tab controls subform to an unbound mainform

      Originally posted by twinnyfo
      Equus,

      I am a little confused by your post, but I think I kinda understand what your problem is.

      First, I'm not sure what you mean by as a procedure is not a set of records that can be used as a record source. However, if what you mean is that you have a stored query (which uses parameters for its criteria), then that makes sense. You have just designed the Form so that it is not bound to that record source at start up. This I understand.

      Second, I don't understand Tab Controls do not have record sources--nor do any of the separate tabs on tab controls. However, if you mean that you inserted a Tab Control with three tabs and each tab has its own subform embedded in the Tab, then I understand that.

      You state This auto-linking did not occur because your main form is not bound. Had the main form had a record source, when you embedded the subforms (this is my assumption here) Access would have tried to find fields within each record source that properly correspond to each other.

      Also, the reason you cannot do this manually, at this time, is, again, because the Form is not bound to a Record Source. If your Form were bound during the design, and you make these Master-Child relationships, you can delete the Record Source and then when the Form opens at run time, when you assign a new record source, the same Master-Child Relationships will be maintained (as long as the corresponding field names are included in the record sources.

      I think this might help to explain what is happening, but I would need more information to trouble shoot.

      Please take some time to describe in a little better details exactly what you have done and how you have constructed your Form.
      Thanks for the quick response. Everything you said is correct. However, I did originally start off with a Record source, then deleted it, but I continued to have challenges. I considering just putting in command buttons to open the subforms instead of using tab controls. Is that a better way to go?

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3662

        #4
        As long as you build your form with the record source, you should be fine. Then, before you are ready to publish your Form, remove the record source, since you will be assigning the record source after it opens. Not the most orthodox way of doing it, but it can be done that way.

        Normally, I would have the Form have the query as its record source (the same query you are using now--but without the parameters/criteria). Then, use the form to filter the record source. That would alleviate any confusion the sub forms might have with its record sources.

        Hope that hepps!

        Comment

        • Equus57
          New Member
          • Oct 2014
          • 4

          #5
          How DO I link A tab control subform to the mainform that is unbound?

          Originally posted by twinnyfo
          As long as you build your form with the record source, you should be fine. Then, before you are ready to publish your Form, remove the record source, since you will be assigning the record source after it opens. Not the most orthodox way of doing it, but it can be done that way.

          Normally, I would have the Form have the query as its record source (the same query you are using now--but without the parameters/criteria). Then, use the form to filter the record source. That would alleviate any confusion the sub forms might have with its record sources.

          Hope that hepps!
          I plan to try a few different options unless I get a better suggestion from someone. Thank you very much!

          Comment

          Working...