Reputation: 1069
So I have created a Table and a Form, which allows you to Save New Record to the table, by entering some fields.
Everything works fine, except that while clicking "Save New Record" button, the new entry is NOT saved, but it Edits the previous entry!
So no more then 1 record is inside the Primary Table.
Could it be something with Relationships ?
I have two tables:
PrimaryTable
ContactsTable
Both have the same name as Primary Key and are connected via that Key (inside relationships).
If you need more information or some screenshtos, pleaese let me know in comments!
CODE FOR SAVE NEW RECORD:
Private Sub onSaveBtn_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
End Sub
Thanks, David
Upvotes: 1
Views: 162
Reputation: 2013
Since you created your form through the wizard it is likely a bound form. This means that as you edit information in the form you are editing the records directly. When you open your form if there is already data populated then the command you have included in your button DoCmd.RunCommand acCmdSaveRecord
is going to save the information displayed on the form to whatever record was open.
There are a few ways you can deal with this issue. At the bottom of your form you may have navigation buttons and one with a * icon beside it. This indicates create a new record and will clear the form and move it to a blank record when pressed.
You can also add a button on your form with the following code that will do the same thing.
DoCmd.GoToRecord , , acNewRec
Another option you have is to create an unbound form that will allow you to completely control how your users navigate your data.
Upvotes: 1