Results 1 to 12 of 12
  1. #1
    al8876 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    10

    Add New Record in Exisitng Table

    Hi there!



    I am extremely new to Access so thank you for helping me with this issue!

    I am trying to use a form to add new data to an existing table I have.

    As an example, the table I have has the Primary Key ID, Name of Actor, and Movie.

    I created a form and a button with "Add New Record"

    But whenever I add a new record, it replaces the first record of the already existing table, THEN it will add new records to the back of the data set.

    I'm sure there's something that I'm just not doing properly.

    Thanks for the help!!!!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It may be helpful, as an exercise, to create a query. Within Access, you can create, name, and save as query object. Use the Ribbon at the top of Access. Under the Create tab, there is an option to launch the Query Designer. Click the Query Design button within the Ribbon. Then, select your table from the Show Table dialog. Add fields to your query by double clicking the Field names.

    You can save your Query and give it a name, e.g. qryForFormOne. Within the ribbon, you can view your query in "Data Sheet View". This will look very similar to viewing your table in datasheet view. However, queries are more powerful than using, simply, tables.

    When designing your query, you can change how your data is retrieved by Sorting, adding criteria, employing functions, etc. It is usually a good idea to use a Query as a Form's recordsource.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Post code behind the button.

    Why would 'Add New Record' replace data or actually add new records? Is there code that automatically inputs values to fields? Apparently you are not moving to new record row first.
    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.

  4. #4
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    It could be that you open the form on an existing record then when you add new data and save it, it will just over write.

  5. #5
    al8876 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    10
    Thanks for the support! I'll try out all methods

  6. #6
    al8876 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    10
    What code should I put in? I am still very new to this

  7. #7
    al8876 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    10

    Make ID constant through code

    Hi,

    I am still very new to Microsoft Access so any help is greatly appreciated.

    I am having trouble with the form I am creating.

    To give you some background, I have a table set that has existing records (around 5000). Right now I am using test tables because I don't want to experiment with the good table as it is a ODBC table. My task is to make a form that allows employees to enter their information into the form, and an automatic record will appear at the BOTTOM of the data set.

    I made a form with all the credentials needed by the employees, and added the "add new record" button to the form.

    The form works great adding the data to the bottom of the record, except for one big problem. When ever I close the form and re open it, or shut down access and re open it, when entering data into the form, it will ALWAYS replace the first record from the information of the first entry, and then go on to adding more records to the bottom of the data set once the first entry is over.

    I cannot figure this out I've tried make several test tables and forms, but all seem to have the same problem.

    Is there any code I can add into the VBA that will sort this out?

    Unfortunately I cannot make a query (Which would have been my choice) a table is needed.

    Thanks for the help!!!!

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Post the code you already have behind button.
    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.

  9. #9
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    The form will always open on the 1st record. Hopefully you dont have any code that modifies data ON OPEN.
    If so, remove it. Only modify when you are sure of what record you are on.

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I'd like to go back to post 1.
    What exactly are you trying to do? Do you have a clear description that you could show others?

    As an example, the table I have has the Primary Key ID, Name of Actor, and Movie.
    What does this table represent to you? Couldn't you give it a more meaningful name-- to help you and others understand the table/purpose??

    You really should work through some tutorials on database concepts before jumping into Access.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Threads merged.

    As already requested, post the code you already have.

    Or provide db for analysis. Follow instructions at bottom of my post.
    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.

  12. #12
    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
    We really need to see the code behind your "Add New Record" button, as has been asked for previously, but assuming that it is standard code for this, your description
    Quote Originally Posted by al8876
    whenever I add a new record, it replaces the first record of the already existing table, THEN it will add new records to the back of the data set.

    it sounds as if you're entering data into the first displayed Record, overwriting the existing data, THEN hitting the "Add New Record" button, expecting it to save the newly entered data into a New Record! That's how MS Word works, if you modify an existing document, but not how Access works! You have to first hit the "Add New Record" button THEN enter data for the New Record.

    When you hit the "Add New Record" button, after entering data for the first New Record, it is saving the new data in the existing, first Record, then taking you to a New Record, at the back of the file, which is why subsequent New Records are being saved properly.

    Linq ;0)>

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

Similar Threads

  1. Replies: 4
    Last Post: 02-18-2015, 11:28 AM
  2. Replies: 4
    Last Post: 01-20-2015, 12:55 PM
  3. Using DCount to check for exisitng records
    By dylcon in forum Programming
    Replies: 15
    Last Post: 06-11-2013, 02:35 PM
  4. Replies: 3
    Last Post: 08-09-2012, 01:49 PM
  5. Replies: 1
    Last Post: 11-25-2011, 11:16 AM

Tags for this Thread

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