Page 1 of 5 12345 LastLast
Results 1 to 15 of 64
  1. #1
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56

    Auto Populate a new record from a form with data from the current form

    Help! I know this should be easy but being new to Access I am struggling.


    I have a form. One of the fields on the form is "NCRnumber" which is auto generated. I have another Field called "CARnumber" which is empty field. I want to put a button next to the "CARnumber" that will call the CARform to add a NEW CARform Record but I want to pass the "NCRnumber" from the NCRform to the "NCRNmuber on the CARform. The CARform will auto generate a "CarNumber" then return back to the NCRform and populate the "CARnumber" from the CARform.

    Thanks,

    Bob

  2. #2
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    OK I git this far From the NCRForm this calls the Corrective Action Form and adds a NEW Record

    Private Sub Command149_Click()
    DoCmd.OpenForm "Corrective Action Form", acNormal, "", acAdd, acNormal
    Forms![Corrective Action Form]![NCRNumber] = Me.[NCRNumber]
    End Sub
    ------------------------------------------------------------------
    Now I need the "Corrective Action Form" to Return to the "NCRform" and fill in the NEW "CARnumber" it created in the "CARnumber" filed of the NCRform

    Thanks,

    Bob

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The [Corrective Action Form] can reach back into the [NCRForm] through the FORMS collection just as you have done reaching into the [Corrective Action Form] from the [NCRForm] after it was open.

  4. #4
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    Ok I am not familiar with Form Collection.
    Can you give me an example?

    Bob

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This line you used is using the FORMS collection:
    Forms![Corrective Action Form]![NCRNumber] = Me.[NCRNumber]

  6. #6
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    ok I attached this to a button in the NCRform

    Private Sub Command149_Click()
    DoCmd.OpenForm "Corrective Action Form", acNormal, "", acAdd, acNormal
    Forms![Corrective Action Form]![NCRNumber] = Me.[NCRNumber]
    Exit_Command149_Click:
    Exit Sub
    Forms![Corrective Action Form]![CARNumber] = Me.[CAR#]
    End Sub

    -------------------------------------------------------------
    All owrks excpet for
    Forms![Corrective Action Form]![CARNumber] = Me.[CAR#]

    It does not copy the "CAR"Number back to the NCRform

    Bob

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This line:
    Forms![Corrective Action Form]![CARNumber] = Me.[CAR#]
    ...needs to be in the [Corrective Action Form] OnUnload event and read:
    Forms![NCRForm]![CAR#] = Me.[CARNumber]

  8. #8
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    Tried it still foes not work.

    I am calling the Corrective Action Form from a button on the NCRform
    When I add the new record to the Corrective Action Form and exit I want the CAR# to be populated with the new record I just created.

    I am missing something?

    Bob

  9. #9
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    Ok I get a syntax error fo rthe following

    Private Sub Form_Unload(Cancel As Integer)
    Forms![NCRform]![CAR#] = Me.[CARNumber]
    End Sub

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try the same code in the AfterUpdate event of the [Corrective Action Form] form instead.

  11. #11
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    No error this time but it did not work

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Display your value in a MsgBox before you copy it to the other form to see what you have.

  13. #13
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    The Value comes back NULL

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Bingo! The form is in Add Mode and moves to a new record when the current one is saved. Move your code to the BeforeUpdate event of the form instead. That should correct this issue.

  15. #15
    bobfin is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Location
    https://t.me/pump_upp
    Posts
    56
    Still did not copy the value over.

    Bob

Page 1 of 5 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Auto-populate form question: again!
    By revnice in forum Access
    Replies: 5
    Last Post: 08-06-2010, 04:02 PM
  2. Auto-populate form question
    By revnice in forum Access
    Replies: 19
    Last Post: 08-06-2010, 01:01 PM
  3. Replies: 3
    Last Post: 10-05-2009, 07:22 AM
  4. Auto Populate Data from Main Form
    By billiejean in forum Forms
    Replies: 0
    Last Post: 08-05-2009, 08:08 AM
  5. Auto populate fields on a form
    By ldarley in forum Forms
    Replies: 0
    Last Post: 08-14-2008, 09:39 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