Results 1 to 4 of 4
  1. #1
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72

    new record is added against my will

    Click image for larger version. 

Name:	captura_dudas_Access.PNG 
Views:	16 
Size:	28.5 KB 
ID:	37492


    Hello everyone,



    I have a form which is formed by a table and I associated a text which will always appears when I add a new record.

    The way it works the text is like this:
    Also, it was solved in this forum two weeks ago (https://www.accessforums.net/showthread.php?t=75591)

    Code:
     Private Sub Form_Current()
    
                    If Me.NewRecord Then Me.OBSERVACIONES = Dlookup ("texto", "Table")
    
    End Sub
    The problem I am facing is when I browse through all records, especially by using "Go to the next record" a new blank record is created when I click on it (when I am at the last record) and that is what I do not want in my application. I suppose that having this default text is enough to create the record.

    Is there anything I can do in order to stop this?

    I am thinking of adding like a message to confirm if a new record is introduced and it must be accepted in order to create the new record.

    Thank you in advance,

    Regards.

  2. #2
    Join Date
    Apr 2017
    Posts
    1,673
    I think you have a problem because some field in table has default value, and the table has autonumeric ID. When you move to new record in form, the field gets it's default value, and because this, the autonumeric PK for record is created.

    Use default values only for form controls instead. And to be sure, even then abort creating of new record pressing ESC (2 times, when I remember correctly).

  3. #3
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Thank you ArviLaanemets for answering.

    Could you specified me more what do you mean by using default values only for form controls? Please.

  4. #4
    Join Date
    Apr 2017
    Posts
    1,673
    Lets say, tou have a table
    tblYourTable: AutoNumericID, SomeDate, ...

    When you set for SomeDate a default value "=Date()", and add a new row into table (in table, or in form), the field SomeDate gets today's date as value automatically. As now one field in table has non-zero value, the AtonumericID field gets also a value.

    When you don't set default value for SomeDate, but instead you set a default value "=Date()" for text control txtSomeDate (which has SomeDate as source), the control gets default value automatically, but not field SomeDate. The value in control is saved into table when the record is saved, but until then all fields linked to controls in form are empty, and because that the field AutonumericID is empty too.

    In form, when you created a new record, but didn't save it jet, or moved to another record (what forces saving), pressing ESC twice cancels new record creating and returns the record pointer to current last record in table.

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

Similar Threads

  1. How to set focus on record just added
    By GraeagleBill in forum Forms
    Replies: 10
    Last Post: 03-08-2016, 10:38 PM
  2. added Notes and shows on every record
    By Stephanie53 in forum Forms
    Replies: 8
    Last Post: 06-06-2013, 11:43 AM
  3. Replies: 3
    Last Post: 05-13-2012, 07:31 AM
  4. New record not being added to main form
    By hmcquade in forum Forms
    Replies: 10
    Last Post: 07-21-2011, 10:07 AM
  5. Replies: 5
    Last Post: 06-29-2010, 01:24 PM

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