Results 1 to 4 of 4
  1. #1
    KrisAK is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    2

    Can this be done: A Form to Copy-and-Paste (and Revise) Hundreds of Many-to-Many Relationships?

    I know Excel/VBA pretty well, but haven't yet jumped to Access beyond playing around a bit, and I'm wondering if it can pull-off a particular task.

    In short, I'm hoping to provide a tool that generates an overview document that maps Projects to Locations: a matrix, really, like one of those product-feature comparison grids you see on web pages. At its most basic, this suggests three tables: 1) a Project Table, 2) a Location table, and 3) a 'junction' or 'associate' table to manage the many-to-many relationship. (Stop me if I'm way off track.)

    Here's the trick: what I need is the ability to rapidly bulk-assign many Locations to a single Project. As in, once a new Project is defined, I'd like to be able to pull up an 'Assigned To' form into which I can paste hundreds of Location Numbers, possibly via cut-and-past from a column in existing Excel documents. (Location Numbers are used internally, and I'd be using them as keys in Access.)



    So, could a form be designed that would allow me to select a Project, probably via a drop-down, and then bulk-paste Location Numbers? Maybe allowing me to first delete the existing assignment records in the junction table?

    I've found examples of many-to-many designs, but none that handle the sort of bulk assignment as I've tried to describe it here.
    Any pointers would be appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Entire columns can be copy/pasted from Excel into an Access table. I've never tried in a form (in datasheet view).

    However, what you might really want is an INSERT SELECT action SQL. Something like:

    CurrentDb.Execute "INSERT INTO [junction table](ProjectID, LocationID) SELECT " & Me.ProjectID & ", LocationID FROM Locations"

    This action would create a record in the junction table for each and every Location and associate with specified Project. If you want to be restrictive on the Locations, that will be more complicated and can be accomplished several ways.

    Why would you need to delete records from the junction table?
    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
    KrisAK is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    2
    I think you might be on to something. (I only just discovered the concept of datasheet views and sub-forms...like I said, I'm new.)

    While I'd hoped to avoid coding, a hybrid data-entry form with a few scripted buttons ("Clear All Current Entries", etc.), and the ability to past columns into a datasheet subform (which I've yet to try) might be one approach.

    And to answer your question, "why would they need to delete records," sometimes projects are reassigned, and for consistencies sake it would be easier to zap all current records, and paste in the updated list.

    Thanks!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Probably easier to run an UPDATE sql action to change the assignment (of what - manager?).
    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: 3
    Last Post: 03-19-2015, 02:11 PM
  2. Replies: 1
    Last Post: 11-25-2014, 01:42 PM
  3. Replies: 1
    Last Post: 07-08-2014, 02:06 PM
  4. Copy/paste/rename a field in the same form?
    By Jamesiv1 in forum Access
    Replies: 5
    Last Post: 04-26-2014, 10:22 AM
  5. Copy and Paste Row (vb)
    By Computer202 in forum Programming
    Replies: 7
    Last Post: 03-28-2014, 01:59 AM

Tags for this Thread

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