You may need to create a button to clear all controls in a form. If so, then the below MS Access clear form VBA code will help you to do so by clearing all textboxes instead of clearing them separately especially if you have lots of textboxes.
VBA Code to clear all textboxes on a form
1 2 3 4 5 6 |
Dim X As Control For Each X In Me.Controls If TypeOf X Is TextBox Then X = Null End If Next X |
In fact, it is something that is really simple. However, you only need to place a control button into the form. Then, choose the control button option from the toolbox while you are in design mode and paste the VBA code there.
In addition, the above VBA code is very useful especially if you need to save the current record and navigate to a new record. So, in order to navigate to a new record, you can use the following VBA code:
1 |
DoCmd.GoToRecord , , acNewRec |
Consequently, you may need to download the below sample for best understanding of the above VBA Code.
For more pro MS Access Programs, please visit our home page here.
To use Microsoft Access Programs.
You’ll need to have Microsoft Office installed including the bundle of MS Access or to download the free Microsoft Access 2016 run-time.