How to make linked SUBFORM only allow entry for one record.

Posted on 2004-11-20
Last Modified: 2012-06-21
I need my subform to allow only one record to be entered.  When I turn the addrecord property to no, it doesn't allow me to add a record.  I would like to allow me to add one record but not a second.

Thank you.
Question by:Shaft960

    Expert Comment

    There may be a better way but.......
    What if you set the addrecord property to No, but add a record (null or "" in a given field) using code when the form loads.  To add the record you could use an ADO recordset or maybe Docmd.  The user then types over the empty field with their data.
    You could then set the form up to look like it is a one to one.  May not be the tidiest but should work.
    LVL 8

    Accepted Solution

    Open the form with it set to addrecord = yes In your afterupdate statement on the subform do a switch back to addrecord equals no

    Unless you actually only want a single record for each main record.

    If so better solutions, Is the sub form a separate table?

    If so link the two table with a left join query from main table to sub table. Base the form on this. Make a 1:1 relationship. Done.

    Subforms really are ore for a 1:M relationship.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now