For i = 1 To jilu
If IsNull(Forms!定额明细总表1!CPLX) Then
Else
If Forms!定额明细总表1!CPLX = "主机" Then
AAA = Forms!定额明细总表1!编号
BBB = Forms!定额明细总表1!CPBM
sum = 0
DoCmd.GoToRecord , "定额明细总表1", acFirst
For j = 1 To jilu If (Forms!定额明细总表1!CPLX = "组件" Or Forms!定额明细总表1!CPLX = "零件") Then
If Forms!定额明细总表1!CPBM Like BBB & "*" And Len(Forms!定额明细总表1!CPBM) < 8 Then sum = sum + Forms!定额明细总表1!CLGYZJE
End If
End If
DoCmd.GoToRecord acDataForm, "定额明细总表1", acNext
Next
DoCmd.GoToRecord acDataForm, "定额明细总表1", acGoTo, AAA
Forms!定额明细总表1!CLGYZJE = sum
End If
End If
DoCmd.GoToRecord acDataForm, "定额明细总表1", acNext
Next
DoCmd.Close acForm, "定额明细总表1"
End Sub作者: shitou1ge 时间: 2009-4-7 15:36
有时去掉 Or Forms!定额明细总表1!CPLX = "零件" 这一句 zzz就能显示 但是不包括 zzz\001和zzz\003的值了作者: koutx 时间: 2009-4-7 16:08
你把如下不等于"主机"的语句块放在等于"主机"的If条件中,当然不会得到你想要的结果啦。
If (Forms!定额明细总表1!CPLX = "组件" Or Forms!定额明细总表1!CPLX = "零件") Then作者: shitou1ge 时间: 2009-4-7 16:37
不是的 你看DoCmd.GoToRecord , "定额明细总表1", acFirst 这一句 是又从第一条记录开始查找的 作者: shitou1ge 时间: 2009-4-7 16:38 作者: koutx 时间: 2009-4-7 17:33 本帖最后由 koutx 于 2009-4-7 17:41 编辑
If Forms!定额明细总表1!CPLX = "主机" Then'看看这条If语句的End If在什么位置????
AAA = Forms!定额明细总表1!编号
BBB = Forms!定额明细总表1!CPBM
sum = 0
DoCmd.GoToRecord , "定额明细总表1", acFirst
For j = 1 To jilu' 此For循环块只会运行最后一句!
If (Forms!定额明细总表1!CPLX = "组件" Or Forms!定额明细总表1!CPLX = "零件") Then
If Forms!定额明细总表1!CPBM Like BBB & "*" And Len(Forms!定额明细总表1!CPBM) < 8 Then
sum = sum + Forms!定额明细总表1!CLGYZJE
End If
End If
DoCmd.GoToRecord acDataForm, "定额明细总表1", acNext'只运行此一句
Next
DoCmd.GoToRecord acDataForm, "定额明细总表1", acGoTo, AAA
Forms!定额明细总表1!CLGYZJE = sum
End If' 在这那作者: shitou1ge 时间: 2009-4-7 19:34 本帖最后由 shitou1ge 于 2009-4-7 19:49 编辑