Results 1 to 5 of 5
  1. #1
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501

    fill some fields when opening form as acFormAdd

    I have a check box in a form 1. When that check box is checked I have it open a form 2. I would like to fill in a few of the fields in form 2 from data in form 1 when the form opens.



    Will I need a completely separate form for this or can i somehow write some vba so that when i open the form with this vba code i can specify for just that action to include default values from form 1:

    DoCmd.OpenForm "f_RissForm", , , , acFormAdd

    Form 1 has a car id in it. When i open form 2 it will create a new record in another table. I want to have it default to the current car id on display in form 1 when i open form 2.

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    use the full paths (use the builder if you dont know)

    DoCmd.OpenForm "f_RissForm", , , , acFormAdd
    forms!
    f_RissForm!txtBox = forms!form1!txtBox


  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    DoCmd.OpenForm "f_RissForm", , , , acFormAdd
    Forms!
    f_RissForm.CarID = Me.CarID

    using the appropriate control names. Repeat for as many fields as necessary.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    Thank you for your replies. I have done as you suggested and it is working, However, it is also causing a problem with the form.

    This form is created to show all the data records.
    My users want it opened to a filtered set of records
    i have done this by creating form with a button and a query and when you open the Riss form from the button it works properly and only shows the filtered records. (used the Open form Macro with the Filter name of the query created to filter the records)
    Now I have written some vba to open the riss form when a checkbox is clicked on a different form. This is when it will load the car id as the default for the new record.

    The problem is that since I have written that code the button that opens the riss form with a filtered set of data no longer works. It now opens the form blank and it shows filtered in the bar at the bottom but has zero records. If you click the filtered button it will show all the records. If you click the filtered button again it then properly shows only the filtered records.

    The only thing I can think of is that once the form has been opened to just add a new record it is somehow remembering that.

    What can I do to fix this? It confuses me.

  5. #5
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    Update, Not sure how it happened but the form Data entry property got saved to yes. the only thing I can think of is that i opened the form from my check box, which would have set the form Data Entry to yes. Then i must have made a design change, moved a box or something, and then saved it. This would have then saved the Data Entry option.

    It is now working like I want. I thank you all for your help.
    Tate

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

Similar Threads

  1. Replies: 2
    Last Post: 06-13-2017, 07:53 AM
  2. Replies: 12
    Last Post: 08-20-2014, 05:26 PM
  3. Replies: 3
    Last Post: 03-21-2012, 01:43 PM
  4. Auto-Fill text fields in the form
    By sk88 in forum Access
    Replies: 2
    Last Post: 01-10-2012, 08:22 PM
  5. How To Fill In Multiple Fields From A Form
    By SamanthaSamuels in forum Access
    Replies: 3
    Last Post: 08-16-2010, 12:13 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