Results 1 to 4 of 4
  1. #1
    jcaswell is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    5

    Passing data between forms, and using it in the receiving form

    I am managing a many-to-many relationship using the below form. This is called by a previous form, and the Element name 'Deskware Hardware' is passed in. The form only shows the Components that are linked to Desktop Hardware (there is a many-to-many relationship between Element and Component that is resolved throough a link table). In this case, I want to add more Components to the given Element, but this table will allow the user to pick any Element/Component combination to add, but I want to constrain it to this Element.



    So - what I would like to do is to stop update of the Element column, but whenever they add a new Component using the Combo box, the Element name and ID (the second column) are automatically added. I know I can set the Component field up so when it changes, I can take an action, and in this case I would like to automatically add the Element Name and ID.

    How can I do this?

    Click image for larger version. 

Name:	Capture.PNG 
Views:	17 
Size:	19.2 KB 
ID:	8517
    Attached Thumbnails Attached Thumbnails Capture.JPG  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    The Element and Component are in the same table? You could have code that will set the DefaultValue of ElementID field. http://access.mvps.org/access/forms/frm0012.htm

    Why are you saving the Element name and Component description?
    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
    jcaswell is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    5
    Element and Component information are in two different tables, and each one has an ID. There is a many-to-many relationship between them, so I have a link table that contains the IDs of the linked pairs. The form contains the results of a join of the two main tables and the link table, using the Element ID to initially populate it, showing initially only the links already established for that Element. It allows me to delete links that i no longer need by pressing the Delete buton (it only deletes the link), and also allows me to establish new links using the down arrows to select new link pairs. Thus although I am showing the descriptions, I only do that to allow easy selection. The thing that is saved is the pair of Element ID and Component ID in the Link table.

    In this case, a previous form was allowing the user to update a particular Element (Desktop Hardware), and they had a button to allow then to establish the links to Components. That form called the one being shown, passing the Desktop Hardware ID. this form was initially populated with the existing links for Desktop Hardware, and allows the user to add more, or delete existing ones.

    So the user action in that case is to use the drop-down arrows in the left column to select Desktop Hardware, and those in the right column to select the Component they want to link to. So, the selection of Desktop Hardware is un-necessary in this case as all pairs will be linked to Desktop Hardware, it is the right column (Component) that needs the selection.

    So, I want to disable the left hand column, and automatically enter Desktop Hardware and its ID (columns 1 and 2) when an entry is made in column 4. The trigger can be set using a function such as 'Got Focus' on the component field when the user makes an entry, but I do need to understand how to get hold of the variables

    Does that help?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Have you considered a form/subform arrangement?

    Want to provide db for analysis? Follow instructions at bottom of my post.
    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. Passing data between forms
    By injanib in forum Forms
    Replies: 2
    Last Post: 07-01-2011, 09:36 AM
  2. Passing Data Between Forms
    By exeTrix in forum Programming
    Replies: 3
    Last Post: 04-05-2011, 01:06 PM
  3. Passing Data from on Form to Another..
    By ETCallHome in forum Forms
    Replies: 2
    Last Post: 03-12-2011, 12:26 AM
  4. Form not passing data to query
    By bobfin in forum Queries
    Replies: 13
    Last Post: 08-11-2010, 05:28 AM
  5. Replies: 3
    Last Post: 06-02-2009, 09:51 AM

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