Results 1 to 6 of 6
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Getting a blank row after a set of data is entered

    Hey guys,



    My office staff uses my Access program for data entry of customers names and info. When they key the last name on their list, they usually hit "New Record." They are under the mentality that it is more of a "Save last record" button. This leaves me with a bunch of blank rows in my database.

    This isn't a big deal as of yet, but as the database grows, so will the blanks. I was just curious if there is a way of not creating a record unless certain conditions are met. All of the fields have a validation rule of "is not null" but it never gets to that point when they just hit "new record" and then close out of the form.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Why does moving to new record row commit a blank record in table? Is New Record a custom button? What is the code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    It's a single form. New record button is custom, it copies some of the data that we want to stay the same until changed by the user.

    Code:
    Dim subdate As String
    Dim galleytype As String
    Dim custtype As String
    Dim storenum As String
    Dim Salesperson As String
    Dim addate As String
    
    
    
    
        subdate = Me.Entry_Date
        galleytype = Me.Galley
        custtype = Me.Type
        storenum = Me.Store
        Salesperson = Me.Salesperson
        addate = Me.Sale_Date
            
        DoCmd.GoToRecord , , acNewRec
        
        Me.Entry_Date = subdate
        Me.Galley = galleytype
        Me.Type = custtype
        Me.Store = storenum
        Me.Salesperson = Salesperson
        Me.Sale_Date = addate
        
        Me.Title.SetFocus
    Now it's obvious as to why that record gets created...

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Here's a snip of the form:

    Click image for larger version. 

Name:	tmw.PNG 
Views:	6 
Size:	44.1 KB 
ID:	16280

    The controls on the bottom right are hidden. The data from the controls on the top in the header are duplicated to those hidden controls After Update, as well as when a new record is added via the custom button.

    What I would love, if it is possible, is:
    -User enters data in the controls in the header
    -User proceeds to fill in the detail section and adding new records (while the header data stays the same and is part of each record in the table)
    -Once a user needs to change which salesperson the data is for, they change that from the combo box in the header, and proceed to the detail section
    -Continue until all sales people's data have been entered

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Instead of code to populate fields because this initiates a record, maybe set the DefaultValue of the controls. The DefaultValue will not trigger until user makes an entry into any field of the new record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    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
    As June7 suggested, to avoid creating a 'blank' Record you can use the AfterUpdate event of the Control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each New Record, but if no additional data is entered no new Record will be created. The code would be like this:

    Code:
    Private Sub YourControlName_AfterUpdate()
       Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
    End Sub

    This syntax is valid for Text, Number, DateTime and Boolean Datatypes.

    You’ll need to do this for each Control that you want to ‘carry forward.’

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 14
    Last Post: 01-07-2014, 04:20 PM
  2. Replies: 2
    Last Post: 12-18-2012, 11:41 AM
  3. Replies: 2
    Last Post: 07-30-2012, 03:26 PM
  4. Replies: 11
    Last Post: 11-13-2011, 06:57 PM
  5. Unmatched data entered with data in table
    By boreda in forum Access
    Replies: 0
    Last Post: 07-28-2006, 09:11 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