Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subform Data Entry (A2K SR1)

    I hope this is an easy one. I have a form containing a subform. After I populate the final field in a record in the subform, Access automatically creates a new record waiting to be populated. If I exit the subform without populating the new record, however, a blank, zero-value record is created in the underlying table. I don't want that to happen. What am I doing wrong? Thank you for any help you can provide.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Data Entry (A2K SR1)

    Check the default value proprety in the table behind your subform. The Default Value is probably set to all zeros now. You may just want to leave it blank (assuming it's not an indexed field).

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Subform Data Entry (A2K SR1)

    The simplest way to stop that is to use the subform's before update event to test for data in key fields. Only allow the update if certain fields contain data (other than 0, as Mark suggests). Otherwise, cancel the update and undo the record.
    Charlotte

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Subform Data Entry (A2K SR1)

    This is probably happening because you have some code in the OnCurrent event that is populating a field if on a new record, causing the subform record to be "dirtied". When you exit the subform, Access automatically writes the dirty record to the table. Put these initial values as default values, rather than setting them through code.

    You also might want to look at the table behind that subform, and set some validation rules and specify whether/not certain fields are required. This will prevent writing until these fields are correct.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Data Entry (A2K SR1)

    I think I misstated my original problem. Currently, after data is entered in the last field of a subform record, and the user tabs through that last field, a new blank record is automatically created. If the user then exits that form, a blank record is added to the underlying table. I don't want that blank record. Can I stop this?

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Subform Data Entry (A2K SR1)

    Access always display a blank record (called the New Record). Is that what you are talking about. This record really isn't in the table.

    Just to be sure I understand what you are saying. When you tab off the last control on a line, Access writes that record and then move to the next record. If you already on the last line of the form, you are moved to the New Record. If you just tab through this record, nothing will happen. You have to make an entry into a field. The exception to this is when you have some code that does this, like initializing a field when you are on the New Record, etc.

    Look at the record selector on the left side of the form, there should be one for every line. If they aren't there, change the form property to enable them. The record selector for the current active line has a black arrow. As soon as you make an entry in the line, it becomes a pencil; indicating the line is "dirty". Whenever that pencil is there, moving off the line or the subform will cause the record to be written.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Data Entry (A2K SR1)

    The blank record that appears on the form is the default record from Access. If the record is not changed then Access should not save it when you leave the form. As it is being saved then, I guess, you are modifying a field somewhere in code. eg. in the OnCurrent event you format/update the contents of a field.
    Check the default settings for the record fields in the table and compare them to what is actually saved in this blank record. Maybe a zero appears where the field has no default which would make Access think a new record has in fact been created.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •