Results 1 to 2 of 2
  1. #1
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393

    Question Transferring data from form to form when starting new record

    OK so my situation is a simple 1 to many relationship where the main form has the primary key and the secondary input form needs the foreign key to be passed to it to link the 2 tables.



    Say for example 1 Site has many sections (Plants). The main menu form can therefore select the Site and filter to another combo box containing the plants that are attached to that site. The user can then either edit the plant or add a new plant record linked to the site.

    I have figured out how to edit the plant attached to the site using a macro that opens the form Plants with the site ID passed from the main form however when I want to enter a new Plant I still need the site ID passed to the Plants form however using the following code

    DoCmd.OpenForm "frmPlants", acNormal, , , acFormAdd

    It simply opens the form as a new record and therefore will not transfer the SiteID

    No doubt this is not the hardest thing to do I just can't work out how to do it

    I have seen somewhere using code similar to this

    stLinkCriteria = "[SiteID]=" & Me![SiteID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    may help me but I can't seem to get it to work

    Please help

    Thanks

  2. #2
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    Private Sub cmdAddPlants_Click()
    stLinkCriteria = "[SiteID]=" & Me![SiteID]
    DoCmd.OpenForm "frmPlants", acNormal, , , acFormAdd, , stLinkCriteria
    End Sub

    Ok tried many variations of this code, if someone can let me know if I am on right track would be awesome, cannot seem to find SiteID from combo box

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 63
    Last Post: 01-25-2013, 05:20 AM
  2. transferring data from word to access
    By RickScolaro in forum Access
    Replies: 6
    Last Post: 09-08-2011, 05:17 PM
  3. Replies: 3
    Last Post: 08-25-2011, 02:28 PM
  4. Need help on transferring found record
    By awsmitty in forum Access
    Replies: 1
    Last Post: 01-22-2010, 09:11 PM
  5. Replies: 9
    Last Post: 03-24-2009, 09:19 PM

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