Results 1 to 3 of 3
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    New Record

    All using 2010. I have a form that new users can add new records. The problem is every now and then there are blank records without data; just the primary key. How can I prevent this? Is there a way if the user starts a new record and back out the data that the record doesn't save? I don't know what they are doing because they tell me they are not starting the record and not entering any data. I thought about validation; like you can't move forward without completing the record but what if they change their mind about adding a record. Thanks for your help in advance.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Assuming that the PK is an AutoNumber, you've already diagnosed the problem! Your users are starting a Record (all they have to do is to enter one character in one Field) then changing their minds, deleting the entered data then leaving the Form. The AutoNumber is generated as soon as that first character is entered, and voila...you have a Record! What kind of Form is this...Single, Continuous or Datasheet View?

    Asking the user if they want to save or dump the New Record is one approach; this code also asks whether or not they want to save changes that have been made to an existing Record:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Not (Me.NewRecord) Then
      If MsgBox("Would You Like To Save The Changes To This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save Changes to Record ???") = vbNo Then
       Me.Undo
      End If
    Else
      If MsgBox("Would You Like To Save This New Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This New Record ???") = vbNo Then
       Me.Undo
      End If
    End If
    End Sub

    Linq ;0)>

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Thanks for the reply. The form is Single. I figured it was because of the PK. It did occur to me to put something like this code in but i didn't think it would make a difference. But now that you suggested it; I will try it. Thanks again.

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

Similar Threads

  1. Replies: 4
    Last Post: 07-03-2013, 10:02 AM
  2. Replies: 3
    Last Post: 03-09-2013, 10:39 AM
  3. Replies: 2
    Last Post: 12-21-2012, 01:57 PM
  4. Replies: 5
    Last Post: 08-21-2012, 12:30 PM
  5. Replies: 14
    Last Post: 05-25-2012, 02:40 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