opening a form and entering data isn't adding information to table

I have two forms.


from frmAssetsmain a button is pressed to open frmassets to enter data.  The code on that button is:

Private Sub Btn_NewAsset_Click()
DoCmd.OpenForm "Assets", acNormal, , , acFormAdd
End Sub

Once the information is entered on that form, another button is pressed which is supposed to save the record and update the the subform AllAssetsSubform located on FrmAssetsMain to show the new record which was added.  The code I have on that button is:

Private Sub Command86_Click()
On Error GoTo Err_Command86_Click
    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command86_Click
End Sub

Something here isn't working right.  The first button opens up the new form with no problems, and opens it up to add a new record as I wanted, but once that data is entered and the second button is pressed, that information is NOT being saved to the table.  It was working previously when I had just a DoCMD.GoToRecord command on the first button, but then it was always opening up with all the records and displaying the last record in the table instead of opening empty so a new record could just be added.  But once I changed the code to what it is now, it stopped working.  Could someone please tell me the error in my code to make this work?

What it's supposed to do:  Open the frmAssets, enter a record, press a button, save the entry into the table, requery the underlying form to update and show the newly entered information and then go to the next blank record to allow entering of another record.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

ptykwylxConnect With a Mentor Commented:
It's not  DoCMd.Save for saving your record, it is,
DoCmd.RunCommand acCmdSaveRecord
JARichardHIAuthor Commented:
Thank you, that fixed the error with it saving to the table, but what about the going to the next open record automatically after hitting the save button?
If you have an Autonumber field (e.g. ID), maybe you can use a query like this one on the main form,
SELECT tbl.D, tbl.Field2, tbl.Field3
FROM tbl
WHERE (((tbl.ID)=(SELECT Max(tbl.ID) AS MaxOfID FROM [tbl])));
When you requery, you will always have the last one.
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

There's a typing error in my last post, the first line should be,
SELECT tbl.ID, tbl.Field2, tbl.Field3
JARichardHIAuthor Commented:
Well, for that second part of my issue, going to the next empty record all I needed was a DoCmd.GoToRecord,,acNewRec.  Thanks for that first part though, you just lost me on the query thing.
JARichardHIAuthor Commented:
Thanks for this, helped alot I can stop beating my head now.  The second part was actually rather simple.  All I needed was a DoCmd.GoToRecod,,acNextRec   I really gotta learn this coding.  Little bit at a time though
All Courses

From novice to tech pro — start learning today.