Results 1 to 3 of 3
  1. #1
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156

    Prevent automatic creation of blank record on form open.

    Hi, all!



    I'm struggling with a small, yet very crucial form. The form in question enables users to add products to an account.

    The products are made up of a primary type, and a sub type. These two product types are stored in their own tables, and feed into synchronized combo boxes on the form. When the user opens the form from the account screen, it pre-fills the account number (which is passed to the account/product table, to which the form is bound), displays the account name via an unbound box with a DLookup, and allows the user to create a product by choosing the two classes, and clicking the save button. Results then display in the subform below.

    The problem I'm having is that if I open the form and then close it, even without doing anything, it's creating a record on my account/product table with the auto# primary key, and the rest of the record blank. Aside from a waste of space, this is then causing Error messages to display in my subform.

    I've tried some different techniques in VBA that I saw online, but nothing has worked quite right for me. I'm trying to keep a record from generating until the user manually saves it. Does anyone have any suggestions?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can do a few things
    1. Don't use bound forms
    2. Don't 'pre fill' the fields, fill them only after the 'required' information to make the record valid is populate. In this case I suspect you are picking a record from one form, opening a second form and attempting to add records to that 'new' form with a pre-filled field that corresponds to the selected record on the main form. If this is the case, set the LOCKED property of the account number to TRUE, populate it only after other information has been entered.
    3. Set the properties of your table such that you require a certain set of data (your autonumber field may be marked as the primary key but you can require other fields to be present for a record to be valid, if you exit the form without those items being present it should abandon the record (with a warning, but you should be able to suppress that)

  3. #3
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156
    Oh, duh! I went with Option 3. Fixed it! Thanks!

    I do see what you're saying about bound forms, but I haven't been doing Access for long, and have to launch this database by the end of the month. I'll have to come back to that later.

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

Similar Threads

  1. Replies: 3
    Last Post: 12-20-2014, 04:15 PM
  2. Automatic record creation
    By preveo in forum Access
    Replies: 1
    Last Post: 02-18-2014, 11:57 AM
  3. Replies: 3
    Last Post: 11-03-2013, 09:53 PM
  4. Creation of autonumber on open form
    By Pragmatic in forum Forms
    Replies: 1
    Last Post: 12-17-2011, 11:39 PM
  5. Replies: 1
    Last Post: 06-25-2010, 09:56 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