Reputation: 13
I can make a button that fills in required fields to max values for what I need on my forms. But I have them all on separate forms. Is there a way to create a button/checkbox on just my main form that inputs all that info on all the forms/subforms? Rather than have 7 of similar buttons on all 7 forms. Trying to save time and human error when creating new clients...
Currently using Access 2003 but in the midst's of migrating to 2016 (huge jump I know...)
Upvotes: 0
Views: 624
Reputation: 1
It is possible to open forms via code and perform actions onto the textboxes etc. But as Elizabeth Ham said, you would need to specify each action. This can make your main form extremely slow.
Sub EnterDataOnForm()
Dim clsFrm As Form
Set clsFrm = Forms("frmNr1")
clsFrm.txtNr1.Value = "Test 1"
clsFrm.txtNr2.Value = "Test 2"
Set clsFrm = Nothing
End Sub
Upvotes: 0
Reputation: 196
You can do this the same way you did on the main form, but you will need to know the syntax for referencing controls on subforms. Go to the command button and edit the code for the Click event.
Private Sub CommandButtonName_Click()
Me.MainField.Value = "default" 'Set fields on the main form to their default values like this
Me!SubformName.Form!SubformField.Value = "default" 'Set fields on the subforms with this syntax
End Sub
You will have to do this for every field in each subform. It also might be wise to program an "undo" button... I'll leave that up to you!
This is not the most elegant solution, but I think for your purposes the time saved for the users will be worth the time setting the defaults within the command button's event.
Upvotes: 1