meanster99
Meum cerebrum nocet!
- Local time
- Today, 23:42
- Joined
- May 2, 2006
- Messages
- 62
I am a complete newbie to vba and I am sure I end up writing far more code than I need to.
For example I needed to disable all but one control on the oncurrent event of a form and so I wrote:
Me.controlname.Enabled = False
Me.controlname2.Enabled = False
etc
etc
I did this for 13 controls.
Another example
If IsNull(Me.controlname) Or Me.controlname = "" Then
do something
End If
If IsNull(me.controlname2) Or Me.controlname2 = "" Then
do the same thing
End If
etc etc for say 13 more controls.
When I write this I can't help thinking there must be a more efficient way of coding these things in say one or two lines. I am sure there must be a way of referring to multiple controls in one line of code but I don't know what it is!
Can you help me?
For example I needed to disable all but one control on the oncurrent event of a form and so I wrote:
Me.controlname.Enabled = False
Me.controlname2.Enabled = False
etc
etc
I did this for 13 controls.
Another example
If IsNull(Me.controlname) Or Me.controlname = "" Then
do something
End If
If IsNull(me.controlname2) Or Me.controlname2 = "" Then
do the same thing
End If
etc etc for say 13 more controls.
When I write this I can't help thinking there must be a more efficient way of coding these things in say one or two lines. I am sure there must be a way of referring to multiple controls in one line of code but I don't know what it is!
Can you help me?