Y
Yue Zhao
I need to enable or disable a bunch of controls, according to the value
of other controls. for instance, when the checkbox called
Curr_Med_Atripla_Checkbox has a value -1, then I want to enable the
textbox called Curr_Med_Atripla_Length_Textbox.
So here is what I did, and of course,,, it didn't work.
It seems the way I was refering to the control name in Sub
EnableOtherQues was wrong: Access was trying to find the control called
"Me!CtrlNameSub", instead of "Me!Curr_Med_Atripla_Checkbox", even when
CtrlNameSub="Curr_Med_Atripla_Checkbox".
So, what is the right way to do that? Thanks a lot!
' ******
' my codes:
' ******
private sub form_curr()
....
Call EnableOtherQues("Atripla", -1, True, False, _
"Curr_Med_", "_Checkbox", "Curr_Med_", "_Length_Textbox")
end sub
Private Sub EnableOtherQues(VarName, Value, UnderValue, _
Optional OwValue, _
Optional PrefixSub as string, _
Optional SuffixSub as string, _
Optional PrefixObj as string, _
Optional SuffixObj as string)
' When one question is answered with a certain value,
enable/disable another question
' Generate the names of the Subject Control and Object Control
Dim CtrlNameSub As String, CtrlNameObj As String
CtrlNameSub = VarName
If Not IsNull(PrefixSub) Then CtrlNameSub = PrefixSub & CtrlNameSub
If Not IsNull(SuffixSub) Then CtrlNameSub = CtrlNameSub & SuffixSub
CtrlNameObj = VarName
If Not IsNull(PrefixObj) Then CtrlNameObj = PrefixObj & CtrlNameObj
If Not IsNull(SuffixObj) Then CtrlNameObj = CtrlNameObj & SuffixObj
' Enable and Disable
If Me!CtrlNameSub.value = Value Then
Me!CtrlNameObj.Enabled = UnderValue
Else
If Not IsNull(OwValue) Then
Me!CtrlNameObj.Enabled = OwValue
End If
End If
End Sub
of other controls. for instance, when the checkbox called
Curr_Med_Atripla_Checkbox has a value -1, then I want to enable the
textbox called Curr_Med_Atripla_Length_Textbox.
So here is what I did, and of course,,, it didn't work.
It seems the way I was refering to the control name in Sub
EnableOtherQues was wrong: Access was trying to find the control called
"Me!CtrlNameSub", instead of "Me!Curr_Med_Atripla_Checkbox", even when
CtrlNameSub="Curr_Med_Atripla_Checkbox".
So, what is the right way to do that? Thanks a lot!
' ******
' my codes:
' ******
private sub form_curr()
....
Call EnableOtherQues("Atripla", -1, True, False, _
"Curr_Med_", "_Checkbox", "Curr_Med_", "_Length_Textbox")
end sub
Private Sub EnableOtherQues(VarName, Value, UnderValue, _
Optional OwValue, _
Optional PrefixSub as string, _
Optional SuffixSub as string, _
Optional PrefixObj as string, _
Optional SuffixObj as string)
' When one question is answered with a certain value,
enable/disable another question
' Generate the names of the Subject Control and Object Control
Dim CtrlNameSub As String, CtrlNameObj As String
CtrlNameSub = VarName
If Not IsNull(PrefixSub) Then CtrlNameSub = PrefixSub & CtrlNameSub
If Not IsNull(SuffixSub) Then CtrlNameSub = CtrlNameSub & SuffixSub
CtrlNameObj = VarName
If Not IsNull(PrefixObj) Then CtrlNameObj = PrefixObj & CtrlNameObj
If Not IsNull(SuffixObj) Then CtrlNameObj = CtrlNameObj & SuffixObj
' Enable and Disable
If Me!CtrlNameSub.value = Value Then
Me!CtrlNameObj.Enabled = UnderValue
Else
If Not IsNull(OwValue) Then
Me!CtrlNameObj.Enabled = OwValue
End If
End If
End Sub