Clear All fields after Hit the Save button

2019-07-11 03:37发布

问题:

I have working on forms, after i filled all the fields and Click on Save button, all fields have been saved but the text fields was not empty, all entered text still present, How do removed those text after hit on the save button

回答1:

Go to a new record:

DoCmd.GoToRecord , , acNewRec 


回答2:

May be you would like to add the following in the click on save button event before "End Sub"

Me.TextboxName.Value = Null


回答3:

Try this routine linked to a button you want to click to clear all textboxes in an unbound form:

Private Sub CleanAllFieldsButton_Click()
Dim ctl As Control
For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then ctl = Null
Next
Set ctl = Nothing
End Sub


回答4:

Private Sub Command47_Click()
On Error Resume Next
Me.Dirty = False 'Attempt to save the record
If Err.Number = 0 Then
'Only enter a new record, leaving other newly-added record accessible
DoCmd.GoToRecord , , acNewRec
Else MsgBox Err.DESCRIPTION, vbCritical, "Error"
End If
End Sub

Try this is in your save records click event.