|
-
Aug 4th, 2005, 11:54 AM
#1
Thread Starter
Junior Member
the control object...
iv'e tried to write some code that will control the enabled property of other controls.
when one control is checked, then i would want the next control to be enabled, however when the control in un-checked, i want to disable all the controls that follow it (but not the preceding controls)
i'm using access with VBA, so i can't really make anything similar to a control array...
anyways, i tried to make it happen - but i get either a type mismatch, or an error that the object doesn't support this method/property.
is this a VBA limitation, or am i just coding something wrong.
Code:
Sub form_current()
Dim ctr As Control 'this checkbox is checked when things are done
Dim ctr2 As Control 'the controls to enable or disable
For Each ctr In Forms.quotes.Controls
Debug.Print ctr.Name
If ctr.Tag >= 1 And ctr.Tag <= 15 Then 'if the checkbox is checked then
' for the immediate next control which is a dependant of the
' checked control
' if it's more than 2 then it's checked and the loop is finnished
For Each ctr2 In Me.Controls
If ctr2.Tag <= ctr.Tag + 2 And ctr2.Tag >= ctr.Tag Then
If ctr2.Value = True Then
ctr2.Enabled = True
End If
End If
Next
ElseIf ctr.Tag > 1 Then
If ctr.Value = False Then
For Each ctr2 In Me.Controls
If ctr2.Tag > ctr.Tag And ctr2.Tag <= 15 Then
ctr2.Enabled = False
End If
Next
End If
End If
Next
End Sub
ps. 15 is the last control that i want to be controlled by this behavior
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|