dellehurley
Board Regular
- Joined
- Sep 26, 2009
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
Hi
I need a shortcut as the code I am writing is very long and bulky. I'm sure there is a shortcut but I cannot find the answer online.
I have a database with a userform, a number is places in the box circled in red, this represents the number of entries there are for this particular file. I want to close the fields which do not apply.
Currently I write the code like this
this continues until I have up to each set of boxes listed then I move on to if Me.texRecs.Value =2
I know there must be a shortcut so I don't have to write out each line for each scenario.
Any advice?
Thanks
Dannielle
I need a shortcut as the code I am writing is very long and bulky. I'm sure there is a shortcut but I cannot find the answer online.
I have a database with a userform, a number is places in the box circled in red, this represents the number of entries there are for this particular file. I want to close the fields which do not apply.
Currently I write the code like this
VBA Code:
If Me.txtRecs.Value = 1 Then
Me.txtRIN1.Enabled = True
Me.txtSurname1.Enabled = True
Me.txtFirstName1.Enabled = True
Me.txtYOB1.Enabled = True
Me.cmdAdd1.Enabled = True
Me.txt1.Value = "a"
Me.txtRIN2.Enabled = False
Me.txtSurname2.Enabled = False
Me.txtFirstName2.Enabled = False
Me.txtYOB2.Enabled = False
Me.txtRIN3.Enabled = False
Me.txtSurname3.Enabled = False
Me.txtFirstName3.Enabled = False
Me.txtYOB3.Enabled = False
Me.txtRIN4.Enabled = False
Me.txtSurname4.Enabled = False
Me.txtFirstName4.Enabled = False
Me.txtYOB4.Enabled = False 'etc
If Me.txrRecs.Value=2 then 'etc
I know there must be a shortcut so I don't have to write out each line for each scenario.
Any advice?
Thanks
Dannielle