By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

Save button on form not working properly

P: 1
Hi all. Hoping to get some help here. I have created the form and it is linked to the correct table. I want to use the "save button" to save the data to the form. Once saved, I want the form on the screen to clear and move on to the next available ID number. I have combed through this forum, but can't seem to find a solution to my issue. I have cut and pasted the code I am using....
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub CommandAddNew_Click()
  4. If Me.NewRecord Then
  5. DoCmd.RunCommand (acCmdSaveRecord)
  6. DoCmd.RunCommand (acCmdRecordsGoToNew)
  7. End If
  8. End Sub
  9.  
  10. Private Sub SAVE_FIGHT_RECORD_Click()
  11.  
  12. End Sub
Thanks for any help!
Mar 28 '18 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,419
Hi Monica.

I'll try to be gentle. I'm guessing you're new to all this.
  1. Never allow any module in VBA to start without an Option Explicit line at the top (Require Variable Declaration). You don't need the extra hassle.
  2. DoCmd.RunCommand acCmdSaveRecord is not the most reliable of commands. I have a routine I use that does that for me as well as documents why it's necessary :
    Expand|Select|Wrap|Line Numbers
    1. 'SaveRec() Saves the current record on frmMe.
    2. Public Sub SaveRec(frmMe As Form)
    3.     'No error handling here.  Should be handled by calling code if required.
    4.     'This code is a little weird but how saving has been implemented in Access.
    5.     frmMe.Dirty = False
    6. End Sub
  3. MonicaJaffe:
    I want to use the "save button" to save the data to the form.
    This doesn't make sense. Forms are objects that allow data to be seen and manipulated. They are not containers of data. The bound table or query is where the data is held (or the table behind the query in that case).
  4. You don't say, but reading between the lines I guess this is a form with the Data Entry property set to True. This means only new records can be selected. If not then it sounds like you may want to set it that way.
  5. Although you indicate you're having problems, you don't actually describe it/any of them.
  6. MonicaJaffe:
    Once saved, I want the form on the screen to clear and move on to the next available ID number.
    I have no idea what you mean by that as I have no information about what you're working with.
With more information we can help more.
Mar 29 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.