Results 1 to 9 of 9
  1. #1
    vicsalt is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Posts
    4

    copy form field values 2 another form

    I have given up and need help

    lets assume the following
    i have 2 tables and 2 related forms
    form 1 has the following fields: name, month, zone
    form 2 has the following: month, zone, action

    on the 1st form i have a button to open the 2nd form ( we will call it "add action")

    what im trying to achiveve:

    click button
    form 2 opens and the fields "month" and "zone" are populated with the corresponding values from form 1.
    i then simply add the action to the remaining field. close the form

    resuly equals table two populated with all data for the record.

    I understand this may not be the best solution but would like to see this work.

    a example would be perfect.

    thankyou

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Open form 2 in data entry mode, right after that line:

    Forms!Form2Name.Month = Me.Month
    Forms!Form2Name.Zone= Me.Zone

    using your actual form and control names. FYI, name and month are both reserved words (names of properties, functions, etc) so shouldn't be used as field names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    I don't understand why you have two tables. Can each month/zone have multiple actions? Will each month/zone associate with multiple names?

    You should be saving a single primary key value into second table.

    Why don't you use form/subform arrangement?
    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.

  4. #4
    vicsalt is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Posts
    4
    once again someone doesnt answer the question

  5. #5
    vicsalt is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Posts
    4
    little more help , is this in the On load event

    Private Sub Form_Load()
    Forms!Form 2.Month = Me.Month
    End Sub


    i get error

  6. #6
    vicsalt is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Posts
    4
    Quote Originally Posted by pbaldy View Post
    Open form 2 in data entry mode, right after that line:

    Forms!Form2Name.Month = Me.Month
    Forms!Form2Name.Zone= Me.Zone

    using your actual form and control names. FYI, name and month are both reserved words (names of properties, functions, etc) so shouldn't be used as field names.
    little more help , is this in the On load event

    Private Sub Form_Load()
    Forms!Form 2.Month = Me.Month
    End Sub


    i get error

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No, behind the button you mentioned. Plus as I said the lines I posted follow the line opening form 2.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In other words:

    DoCmd.OpenForm "Form2",...
    Forms!...
    Forms!...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    There are several ways to pass values to another form.

    1. form/subform arrangement - Master/Child links will automatically pass key value(s) to subform, key can be compound (point of my earlier post was an attempt to advise that with proper normalized data structure there should be no need to duplicate the two fields into second table)

    2. first form fills in controls on second form (Paul's suggestion)

    3. second form reads controls on first form

    4. first form sets OpenForm method OpenArgs argument and second form reads OpenArgs property

    5. first form sets global variables or TempVars which can be read by second form
    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. Copy values from Access form to online webpage form
    By themushroomking in forum Access
    Replies: 5
    Last Post: 07-21-2017, 08:21 AM
  2. Replies: 1
    Last Post: 03-07-2017, 06:32 AM
  3. Replies: 2
    Last Post: 05-28-2013, 12:32 PM
  4. Replies: 2
    Last Post: 03-10-2013, 01:03 AM
  5. Replies: 2
    Last Post: 11-13-2012, 02:11 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