Clear All fields after Hit the Save button

和自甴很熟 提交于 2019-12-23 15:40:10

问题


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.



来源:https://stackoverflow.com/questions/32987928/clear-all-fields-after-hit-the-save-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!