Facilitating data entry in a many-to-many relationship

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • esperance
    New Member
    • Jul 2010
    • 8

    Facilitating data entry in a many-to-many relationship

    I am trying to create forms to facilitate data entry in a many to many relationship. Using Access 2010.
    I am currently working with three tables: a table of images, a table of documents, and a linking table between the two.
    tblImages: ImageID* (autonum), URL (text)
    tblDocs: DocID* (autonum), etc.
    tblLINKImageDoc : ImageID* (num), DocID* (num)
    frmImages contains a subform based on the linking table. What I want to do when I press a cmdbutton is create a new record in the the documents table, save it, then add a record to the linking table which = ImageID of the record I have open when I press the button + DocID of the newly created record. Then it should open a form where I can edit the newly created document record (frmDocs). When I close frmDocs, it updates frmImages.
    Any help would be appreciated. If you need more information, I will do my best.
    Attached Files
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    What about adding a linked sub-sub form for the doc's ?
    (a subform within your subform)

    This will allow adding as many doc's for an image as needed.

    In general I also have such a construction "the other way around", starting with the Doc form as master and the Image form as the sub-sub-form.

    Getting the idea ?

    Nic;o)

    Comment

    • esperance
      New Member
      • Jul 2010
      • 8

      #3
      Thanks for your replay Nico! I was able to add a sub-sub-form (which I didn't know you could do to a datasheet, but it looks beautiful).
      Now this is the problem: to add a record to sbfrmLINKImageD oc the record has to already exist in tblDocs. What method would you suggest to add a new record?
      Attached Files

      Comment

      • esperance
        New Member
        • Jul 2010
        • 8

        #4
        Never mind, I think I have a workaround. My problem really was that I couldn't get the subform to expand from the datasheet. I added a field on the subform with just some garbage, but it seems to instantiate a new record and allow me to open up the subsubform. Thanks for your help! We'll see if this works.
        In fact, I named the field 'Instantiate', set it to a byte, and just type '1' into it. Hilarious. And annoying. But if it works, who am I to complain.
        Last edited by esperance; Jul 17 '10, 08:10 PM. Reason: Amusing anecdote

        Comment

        • nico5038
          Recognized Expert Specialist
          • Nov 2006
          • 3080

          #5
          Forgot to mention that the subform should be changed into a continuous (or single) form first. As you found, the data sheet doesn't support a sub-sub form.

          Adding a doc should trigger the creation of a subform row, when not, you might need some code to insert a dummy Doc first.

          Nic;o)

          Comment

          Working...