Results 1 to 3 of 3
  1. #1
    englek is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2011
    Posts
    1

    passing value to new second form

    I have a primary form (based on a parent table) with a button that opens a second form (based on the child table). The two forms are connected by the primary form's primary key (ID). I would like to have the second form open to create a new record with the ID already filled in to prevent user errors.

    How I can I do this without creating a subform? I looked on previous posts and saw someone suggested putting

    Me.ID.DefaultValue = """" & Me.ID.Value & """"



    in the AfterUpdate but this did not work for me

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    englek -

    Don't know your reason for not wanting to create a subform as it's usually easier. However, be that as it may...

    If I'm not mistaken, the code you referred to only works when you create a new record on the same form.

    In your case, because you are opening a new form. I would try...

    dim transID as long
    transID = Me.ID
    docmd.openform "your2ndformname"
    docmd.gotorecord, ,acNewRec
    Me.ID = transID
    'optional
    'docmd.close "firstformname"

    in the OnClick event of the button.

    Just a thought,

    Jim

  3. #3
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    If your ID is a number (integer, long, etc.) instead of a string then try this:

    Me.ID.DefaultValue = Me.ID.Value

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

Similar Threads

  1. passing variable from modal form to main form
    By crowegreg in forum Forms
    Replies: 2
    Last Post: 06-03-2011, 05:34 PM
  2. Passing parameters from a form
    By rfs in forum Forms
    Replies: 1
    Last Post: 03-15-2011, 12:25 AM
  3. Passing Data from on Form to Another..
    By ETCallHome in forum Forms
    Replies: 2
    Last Post: 03-12-2011, 12:26 AM
  4. Passing value from one form to another
    By Molly152 in forum Forms
    Replies: 4
    Last Post: 11-16-2010, 11:03 AM
  5. Form Help with passing records
    By mwabbe in forum Forms
    Replies: 6
    Last Post: 09-08-2010, 11:06 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