Results 1 to 9 of 9
  1. #1
    AccessNewb89 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    5

    Cool Add Record Button

    Hello All,

    I have a simple table and I created a form for the table in order to make adding new records easier. I created an add record button but when I fill in the fields and press add record all that happens is it brings me to a new form but I want the button to bring me to a new form and store the added data into my table. What am I doing wrong?

    Additionally, once I added the button I could not save the form and got this error:
    "This form or report contains changes that are incompatible with the current database format. The form or report was not saved." It then goes on to tell me to remove any layouts that have empty cells but what does that mean?


    Sorry i'm sure its simple but I just started using access like yesterday.



    Thanks

  2. #2
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    I would suggest you this:
    In the main form have a button something like "Add" and go to event procedure and make it to open new form (like u mentioned) upon clicking it. Then in the new form you can design a layout to have all required fields to fill as in the table and in same order. When the data is entered here, it automatically gets updated in the table. Then at the bottom of this form, have two more buttons like SAVE and ADD NEW and then create a Macro for these two actions.

  3. #3
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    And in your new form, did you link the fields when u enter ur text to the respective fields of the table? (do this in the Propertysheet--> Data--> ControlSource)

  4. #4
    AccessNewb89 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    5
    Yes I linked all the fields in the form to the fields in the table. I think my problem is I don't know what the code should be in order to acomplish the task I want. (I am new to VB and macros altogether)

    This is the code that automatically populated when I created my "add new record" button. I was under the impression that the "add new record" button added a new record to your table and cleared the form so that the user could add another record

    Private Sub SubmitButton_Click()
    On Error GoTo Err_SubmitButton_Click

    DoCmd.GoToRecord , , acNewRec
    Exit_SubmitButton_Click:
    Exit Sub
    Err_SubmitButton_Click:
    MsgBox Err.Description
    Resume Exit_SubmitButton_Click

    End Sub

  5. #5
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Two suggestions:

    First:
    Have an "Add" button that opens a "new" form and have that new form call the same table in a similar form but in "Single Form" and filter to the new record line. You can add a button on this second form that would simply go to the next record, which should save the data entered.

    Second:
    Have the "Add" button open a similar looking form, but remove all binding from the Text Boxes. Add the code below changing the form and Text Box names to suit your needs. The code below closes then reopens the entry form to make inputting more than one new record easier, but you can set it to go back to your main form.

    Code:
    Dim dbs As Database, rst As Recordset
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("Select * from YourTableNameHere")
            
            rst.AddNew
            rst!Field1 = Forms!YourEntryFormNameHere!CorrespondingField
            rst!Field2 = Forms!YourEntryFormNameHere!CorrespondingField
            rst!Field3 = Forms!YourEntryFormNameHere!CorrespondingField
            rst!Field4 = Forms!YourEntryFormNameHere!CorrespondingField
    
        Set dbs = Nothing
        rst.Update
        rst.Close
            
    DoCmd.Close acForm, "YourEntryFormNameHere"
    DoCmd.OpenForm "YourEntryFormNameHere"

  6. #6
    AccessNewb89 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    5
    Thank you for all for the suggestions. For the sake of simplicity, I would like to only have one button and one form if possible to be used for data entry. Let me explain in more detail what I am doing. I have been tasked with making entering data into a database more simple. I simply have a database and would like to have a form with one button which will submit the entered data into the database and clear the form so that the next record may be entered. Multiple people will be using this to enter in the data. Am I just not thinking of accomplishing this in terms of the way Access works? Can I not make a simple modification to the code I already have so that the entered data on the form is stored in my database and so that the form is cleared, ready to accept new data?

  7. #7
    AccessNewb89 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    5
    This seems like a pretty standard task is there some built in function that does this?

  8. #8
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    The "Add New Record" button just jumps you to the open record line your table.

    If your data entry people do not need to review the data, then just have one entry form for them to use, and you can use the code I provided. I can attach a sample database showing the use if needed.

    There isn't a simple built-in function like Excel might have other than having the Form show in 'Continuous Form' and have the users enter data and keep pressing 'Tab' or 'Enter' to get to a new record when they complete the current record.

    EDIT:

    or have them left-click the pencil to the left of the screen when they have completed entering data for the last record.

  9. #9
    AccessNewb89 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    5
    Ok I got it now. Thanks!

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

Similar Threads

  1. Replies: 1
    Last Post: 06-24-2013, 11:31 AM
  2. Replies: 22
    Last Post: 06-12-2012, 10:02 PM
  3. Replies: 4
    Last Post: 07-22-2011, 12:52 PM
  4. Replies: 10
    Last Post: 03-21-2011, 02:46 PM
  5. Replies: 6
    Last Post: 02-09-2010, 07:53 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