|
-
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
-
Aug 4th, 2005, 12:10 PM
#2
Re: the control object...
Why don't you set the tag to the Index of the control when it's checked, and set it to the NEGATIVE Index of the control when it's not.
That way, you could use the click event to multiply by -1, and then call your routine.
Pass the contol number to the routine, so that you start looping there.
-
Aug 4th, 2005, 12:52 PM
#3
Thread Starter
Junior Member
Re: the control object...
you mean... instead of checking to see if the control value is true, just check to see if it's negative?
- that way i can work around the control object not supporting the value property.
i like the idea, and i'll try it out a bit later
please tell me if this is what you mean
-
Aug 4th, 2005, 01:50 PM
#4
Member
Re: the control object...
btw when I add debug.print statements,
It cant even print to the immediate window because it has a runtime error when executing the debug.print statement.
There is a problem accessing the SeriesCollection 6 and 7 values and names.
-
Aug 5th, 2005, 10:19 AM
#5
Thread Starter
Junior Member
Re: the control object...
 Originally Posted by mchow2469
btw when I add debug.print statements,
It cant even print to the immediate window because it has a runtime error when executing the debug.print statement.
There is a problem accessing the SeriesCollection 6 and 7 values and names.
huh??? please explain
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
|