|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm coding a form for MS ACCESS. When I lock/unlock fields, I do so declaring each field. How can I create a SUB that will loop through all the fields and assign the true/false value as needed. So that if I have 20 fields, I don't have to make 20 declarations?
Code is below, Thanks!! JOE Sub LockFields() txtPhone.Locked = True txtFirst.Locked = True txtSS.Locked = True End Sub Sub UnlockFields() txtPhone.Locked = False txtFirst.Locked = False txtSS.Locked = False End Sub --end of code-- |
|
#2
|
|||
|
|||
|
Difficult to say what your intentions are. If you want to loop thru fields you should give them the same name "txtPhone" for ex. This creates an array of input elements and you either make a For Each..Next or For I = 0 to XXX..Next in order to acces each of them succesively.
|
|
#3
|
|||
|
|||
|
Don't know if you are still looking, but I found this in another forumn
Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is TextBox Then ctrl.locked = True ' If TypeOf ctrl Is Label Then ctrl.Caption = "" Next ctrl S- |
|
#4
|
|||
|
|||
|
I haven't done this for quite a while but you should be able to do this through the fields collection. The table object will have a fields collection which you can access in a similar way to an array using an index. I will look into it a bit further but in the meantime, which version are you using?
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > create a loop and assign a value for each field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|