Results 1 to 5 of 5
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Clear Text Boxes After Hitting The Save Button

    Hi



    I have created a form with three textboxes and a button. When i hit the button the records get saved in the table. Now what i want to do is when i hit the saved button after displaying "Saved" Message i want to reset the text boxes to enter new values.

    With my current form when enter a new data once previous data is saved, the previous data get update. i wont records the second data as a new record.

    Please help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Move to new record row.

    DoCmd.GoToRecord , , acNewRec
    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.

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Where to add the above code.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It would get added to my your existing button code. It presumes your form is bound to the table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    The following is an example where the button name is "btnSave" located on some form used to make entry(s) for the table(s) with a Click [Event Procedure]:

    Private Sub btnSave_Click()
    On Error GoTo btnSave_Click_Err
    If Me.Dirty = False Then
    Beep
    MsgBox "No new information to save.", , ""
    Else
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord , "", acNewRec
    End If
    btnSave_Click_Exit:
    Exit Sub
    btnSave_Click_Err:
    Beep
    MsgBox Err.Description, vbOKOnly, ""
    Resume btnSave_Click_Exit
    End Sub

    Just in case you do not know how to add the code for the save button. To add the code open the form in Design View, click the button you are using to save records, open Property Sheet, go to Event tab, for On Click type or select [Event Procedure]. Then press and hold "Alt F11" or click the three little dots to the right of [Event Procedure], which will take you to where the button name_Click() is located. Simply copy and paste the aforementioned code (minus the following) between the Private Sub ...... and End Sub. Now save the newly added code in the VBA Editor and open your form in Form View to test it out.

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

Similar Threads

  1. Save some text fields and clear others
    By whisp0214 in forum Forms
    Replies: 9
    Last Post: 10-25-2017, 03:48 PM
  2. Save last entry in unbound text boxes
    By gunitinug in forum Access
    Replies: 2
    Last Post: 08-29-2017, 07:16 AM
  3. Replies: 6
    Last Post: 01-15-2015, 05:41 PM
  4. Replies: 2
    Last Post: 03-12-2014, 01:31 AM
  5. Populate text boxes with a command button
    By Brian62 in forum Forms
    Replies: 3
    Last Post: 09-30-2011, 12:52 PM

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