你这种情况,只能折中,加一个标志变量即可,如
Do While vars("状态") = "执行中"
application.Doevents
Loop
Forms("窗口2").Open
DataTables("窗口2_Table1").LoadFilter = "入档 = False"
DataTables("窗口2_Table1").Load()
----------------------------
vars("状态") = "执行中"
'------------------表A·入档
Dim st1 As WinForm.Label = Forms("窗口1").Controls("Lab1")
Dim Count1 As Double
Count1 = DataTables("表A").SQLCompute("Count(文件名称)","入档 = True")
If Count1 = 0 Then
st1.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count1 > 0 Then
st1.ForeColor = Color.Red '字体颜色
End If
st1.Text = "" & Count1 & ""
'------------------表A·完成
Dim st2 As WinForm.Label = Forms("窗口1").Controls("Lab2")
Dim Count2 As Double
Count2 = DataTables("表A").SQLCompute("Count(文件名称)","完成 = True")
If Count2 = 0 Then
st2.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count2 > 0 Then
st2.ForeColor = Color.Red '字体颜色
End If
st2.Text = "" & Count2 & ""
'------------------表A·过期
Dim st3 As WinForm.Label = Forms("窗口1").Controls("Lab3")
Dim Count3 As Double
Count3 = DataTables("表A").SQLCompute("Count(文件名称)","过期 = True")
If Count3 = 0 Then
st3.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count3 > 0 Then
st3.ForeColor = Color.Red '字体颜色
End If
st3.Text = "" & Count3 & ""
'------------------表A·废除
Dim st4 As WinForm.Label = Forms("窗口1").Controls("Lab4")
Dim Count4 As Double
Count4 = DataTables("表A").SQLCompute("Count(文件名称)","废除 = True")
If Count4 = 0 Then
st4.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count4 > 0 Then
st4.ForeColor = Color.Red '字体颜色
End If
st4.Text = "" & Count4 & ""
'------------------表B·入档
Dim st5 As WinForm.Label = Forms("窗口1").Controls("Lab5")
Dim Count5 As Double
Count5 = DataTables("表B").SQLCompute("Count(文件名称)","入档 = True")
If Count5 = 0 Then
st5.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count5 > 0 Then
st5.ForeColor = Color.Red '字体颜色
End If
st5.Text = "" & Count5 & ""
'------------------表B·完成
Dim st6 As WinForm.Label = Forms("窗口1").Controls("Lab6")
Dim Count6 As Double
Count6 = DataTables("表B").SQLCompute("Count(文件名称)","完成 = True")
If Count6 = 0 Then
st6.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count6 > 0 Then
st6.ForeColor = Color.Red '字体颜色
End If
st6.Text = "" & Count6 & ""
'------------------表B·过期
Dim st7 As WinForm.Label = Forms("窗口1").Controls("Lab7")
Dim Count7 As Double
Count7 = DataTables("表B").SQLCompute("Count(文件名称)","过期 = True")
If Count7 = 0 Then
st7.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count7 > 0 Then
st7.ForeColor = Color.Red '字体颜色
End If
st7.Text = "" & Count7 & ""
'------------------表B·废除
Dim st8 As WinForm.Label = Forms("窗口1").Controls("Lab8")
Dim Count8 As Double
Count8 = DataTables("表B").SQLCompute("Count(文件名称)","废除 = True")
If Count8 = 0 Then
st8.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count8 > 0 Then
st8.ForeColor = Color.Red '字体颜色
End If
st8.Text = "" & Count8 & ""
'------------------表C·入档
Dim st9 As WinForm.Label = Forms("窗口1").Controls("Lab9")
Dim Count9 As Double
Count9 = DataTables("表C").SQLCompute("Count(文件名称)","入档 = True")
If Count9 = 0 Then
st9.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count9 > 0 Then
st9.ForeColor = Color.Red '字体颜色
End If
st9.Text = "" & Count9 & ""
'------------------表C·完成
Dim st10 As WinForm.Label = Forms("窗口1").Controls("Lab10")
Dim Count10 As Double
Count10 = DataTables("表C").SQLCompute("Count(文件名称)","完成 = True")
If Count10 = 0 Then
st10.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count10 > 0 Then
st10.ForeColor = Color.Red '字体颜色
End If
st10.Text = "" & Count10 & ""
'------------------表C·过期
Dim st11 As WinForm.Label = Forms("窗口1").Controls("Lab11")
Dim Count11 As Double
Count11 = DataTables("表C").SQLCompute("Count(文件名称)","过期 = True")
If Count11 = 0 Then
st11.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count11 > 0 Then
st11.ForeColor = Color.Red '字体颜色
End If
st11.Text = "" & Count11 & ""
'------------------表C·废除
Dim st12 As WinForm.Label = Forms("窗口1").Controls("Lab12")
Dim Count12 As Double
Count12 = DataTables("表C").SQLCompute("Count(文件名称)","废除 = True")
If Count12 = 0 Then
st12.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count12 > 0 Then
st12.ForeColor = Color.Red '字体颜色
End If
st12.Text = "" & Count12 & ""
'------------------表D·入档
Dim st13 As WinForm.Label = Forms("窗口1").Controls("Lab13")
Dim Count13 As Double
Count13 = DataTables("表D").SQLCompute("Count(文件名称)","入档 = True")
If Count13 = 0 Then
st13.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count13 > 0 Then
st13.ForeColor = Color.Red '字体颜色
End If
st13.Text = "" & Count13 & ""
'------------------表D·完成
Dim st14 As WinForm.Label = Forms("窗口1").Controls("Lab14")
Dim Count14 As Double
Count14 = DataTables("表D").SQLCompute("Count(文件名称)","完成 = True")
If Count14 = 0 Then
st14.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count14 > 0 Then
st14.ForeColor = Color.Red '字体颜色
End If
st14.Text = "" & Count14 & ""
'------------------表D·过期
Dim st15 As WinForm.Label = Forms("窗口1").Controls("Lab15")
Dim Count15 As Double
Count15 = DataTables("表D").SQLCompute("Count(文件名称)","过期 = True")
If Count15 = 0 Then
st15.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count15 > 0 Then
st15.ForeColor = Color.Red '字体颜色
End If
st15.Text = "" & Count15 & ""
'------------------表D·废除
Dim st16 As WinForm.Label = Forms("窗口1").Controls("Lab16")
Dim Count16 As Double
Count16 = DataTables("表D").SQLCompute("Count(文件名称)","废除 = True")
If Count16 = 0 Then
st16.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count16 > 0 Then
st16.ForeColor = Color.Red '字体颜色
End If
st16.Text = "" & Count16 & ""
'------------------表E·入档
Dim st17 As WinForm.Label = Forms("窗口1").Controls("Lab17")
Dim Count17 As Double
Count17 = DataTables("表E").SQLCompute("Count(文件名称)","入档 = True")
If Count17 = 0 Then
st17.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count17 > 0 Then
st17.ForeColor = Color.Red '字体颜色
End If
st17.Text = "" & Count17 & ""
'------------------表E·完成
Dim st18 As WinForm.Label = Forms("窗口1").Controls("Lab18")
Dim Count18 As Double
Count18 = DataTables("表E").SQLCompute("Count(文件名称)","完成 = True")
If Count18 = 0 Then
st18.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count18 > 0 Then
st18.ForeColor = Color.Red '字体颜色
End If
st18.Text = "" & Count18 & ""
'------------------表E·过期
Dim st19 As WinForm.Label = Forms("窗口1").Controls("Lab19")
Dim Count19 As Double
Count19 = DataTables("表E").SQLCompute("Count(文件名称)","过期 = True")
If Count19 = 0 Then
st19.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count19 > 0 Then
st19.ForeColor = Color.Red '字体颜色
End If
st19.Text = "" & Count19 & ""
'------------------表E·废除
Dim st20 As WinForm.Label = Forms("窗口1").Controls("Lab20")
Dim Count20 As Double
Count20 = DataTables("表E").SQLCompute("Count(文件名称)","废除 = True")
If Count20 = 0 Then
st20.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count20 > 0 Then
st20.ForeColor = Color.Red '字体颜色
End If
st20.Text = "" & Count20 & ""
'------------------表F·入档
Dim st21 As WinForm.Label = Forms("窗口1").Controls("Lab21")
Dim Count21 As Double
Count21 = DataTables("表F").SQLCompute("Count(文件名称)","入档 = True")
If Count21 = 0 Then
st21.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count21 > 0 Then
st21.ForeColor = Color.Red '字体颜色
End If
st21.Text = "" & Count21 & ""
'------------------表F·完成
Dim st22 As WinForm.Label = Forms("窗口1").Controls("Lab22")
Dim Count22 As Double
Count22 = DataTables("表F").SQLCompute("Count(文件名称)","完成 = True")
If Count22 = 0 Then
st22.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count22 > 0 Then
st22.ForeColor = Color.Red '字体颜色
End If
st22.Text = "" & Count22 & ""
'------------------表F·过期
Dim st23 As WinForm.Label = Forms("窗口1").Controls("Lab23")
Dim Count23 As Double
Count23 = DataTables("表F").SQLCompute("Count(文件名称)","过期 = True")
If Count23 = 0 Then
st23.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count23 > 0 Then
st23.ForeColor = Color.Red '字体颜色
End If
st23.Text = "" & Count23 & ""
'------------------表F·废除
Dim st24 As WinForm.Label = Forms("窗口1").Controls("Lab24")
Dim Count24 As Double
Count24 = DataTables("表F").SQLCompute("Count(文件名称)","废除 = True")
If Count24 = 0 Then
st24.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count24 > 0 Then
st24.ForeColor = Color.Red '字体颜色
End If
st24.Text = "" & Count24 & ""
'------------------表G·入档
Dim st25 As WinForm.Label = Forms("窗口1").Controls("Lab25")
Dim Count25 As Double
Count25 = DataTables("表G").SQLCompute("Count(文件名称)","入档 = True")
If Count25 = 0 Then
st25.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count25 > 0 Then
st25.ForeColor = Color.Red '字体颜色
End If
st25.Text = "" & Count25 & ""
'------------------表G·完成
Dim st26 As WinForm.Label = Forms("窗口1").Controls("Lab26")
Dim Count26 As Double
Count26 = DataTables("表G").SQLCompute("Count(文件名称)","完成 = True")
If Count26 = 0 Then
st26.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count26 > 0 Then
st26.ForeColor = Color.Red '字体颜色
End If
st26.Text = "" & Count26 & ""
'------------------表G·过期
Dim st27 As WinForm.Label = Forms("窗口1").Controls("Lab27")
Dim Count27 As Double
Count27 = DataTables("表G").SQLCompute("Count(文件名称)","过期 = True")
If Count27 = 0 Then
st27.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count27 > 0 Then
st27.ForeColor = Color.Red '字体颜色
End If
st27.Text = "" & Count27 & ""
'------------------表G·废除
Dim st28 As WinForm.Label = Forms("窗口1").Controls("Lab28")
Dim Count28 As Double
Count28 = DataTables("表G").SQLCompute("Count(文件名称)","废除 = True")
If Count28 = 0 Then
st28.ForeColor = Color.DimGray 'Gainsboro '字体颜色
ElseIf Count28 > 0 Then
st28.ForeColor = Color.Red '字体颜色
End If
st28.Text = "" & Count28 & ""
vars("状态") = "执行完成"