Using * wildcard to set enabled property of multiple controls
So I'm using the following code to check if a field has data in it, and if it does, it's enabled property is automatically set to False on form load.
My question here is, I have the following controls: PID1, PID2, PID3, PID4, etc all the way up to PID16. I'd like to use a wildcard, either *, or whatever else works, to set the .enabled property to False if any of those fields from my table that the form is bound to contains data.
The above code works just great for what I am needing, but I'd like to have it work for all the PID* controls, rather than just one and have to write an IF statement for every single control.
Any advice?
So I'm using the following code to check if a field has data in it, and if it does, it's enabled property is automatically set to False on form load.
Code:
Private Sub Form_Load()
If Form![PID1] = Null Then
Form![PID1].Enabled = True
Else
Form![PID1].Enabled = False
End If
End Sub
My question here is, I have the following controls: PID1, PID2, PID3, PID4, etc all the way up to PID16. I'd like to use a wildcard, either *, or whatever else works, to set the .enabled property to False if any of those fields from my table that the form is bound to contains data.
The above code works just great for what I am needing, but I'd like to have it work for all the PID* controls, rather than just one and have to write an IF statement for every single control.
Any advice?
Last edited: