Office中国论坛/Access中国论坛

标题: 条件有一定的规律,请问如何修改 [打印本页]

作者: 真主    时间: 2009-8-26 20:13
标题: 条件有一定的规律,请问如何修改
用选择的值和B_BA_Z000的栏位同名,请问如何简化


    '1
    If Me.Combo_流程 = 1 And DLookup("1", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 1 And DLookup("1", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '2
    If Me.Combo_流程 = 2 And DLookup("2", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 2 And DLookup("2", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '3
    If Me.Combo_流程 = 3 And DLookup("3", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 3 And DLookup("3", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '4
    If Me.Combo_流程 = 4 And DLookup("4", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 4 And DLookup("4", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '5
    If Me.Combo_流程 = 5 And DLookup("5", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 5 And DLookup("5", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '6
    If Me.Combo_流程 = 6 And DLookup("6", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 6 And DLookup("6", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '7
    If Me.Combo_流程 = 7 And DLookup("7", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 7 And DLookup("7", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '8
    If Me.Combo_流程 = 8 And DLookup("8", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 8 And DLookup("8", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '9
    If Me.Combo_流程 = 9 And DLookup("9", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 9 And DLookup("9", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '10
    If Me.Combo_流程 = 10 And DLookup("10", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 10 And DLookup("10", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '11
    If Me.Combo_流程 = 11 And DLookup("11", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 11 And DLookup("11", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '12
    If Me.Combo_流程 = 12 And DLookup("12", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 12 And DLookup("12", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '13
    If Me.Combo_流程 = 13 And DLookup("13", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 13 And DLookup("13", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '14
    If Me.Combo_流程 = 14 And DLookup("14", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 14 And DLookup("14", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
    '15
    If Me.Combo_流程 = 15 And DLookup("15", "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
    ElseIf Me.Combo_流程 = 15 And DLookup("15", "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
    Else
    End If
作者: tanhong    时间: 2009-8-26 23:53
象这个我想用循环语句应该可以:
  1. Dim I
  2. For I = 1 To 15
  3.     If Me.Combo_流程 = I And DLookup(CStr(I), "B_BA_Z000", "SSNameID= ctNameID") = 2 Then
  4.     ElseIf Me.Combo_流程 = I And DLookup(CStr(I), "B_BA_Z000", "SSNameID= ctNameID") = 1 Then
  5.     Else
  6.     End If
  7. Next I
复制代码





欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3