|
本帖最后由 roych 于 2011-4-19 15:03 编辑
回复 wangxy689 的帖子
前面也说得很清楚了,估计是代码过于复杂无法执行的问题。由于涉及全部字段,所以改为星号(*)后即可运行。详细看附件。修改后代码如下:
- Sub 抽样查询()
- Dim ssql As String
- Dim n As Long
- Dim i As Long
- Dim j As Long
- Dim str As String
- Dim strwh As String
- If IsNull(Me.年度.Value) = False And IsNull(Me.月度.Value) = False And IsNull(Me.抽样比率.Value) = False Then
- ssql = "DELETE * from 临时表"
- CurrentDb.Execute ssql
- For i = 0 To Me.保全受理类型.ListCount - 1
- For j = 0 To Me.审核员工号.ListCount - 1
- strwh = "year(申请时间)=" & Me.年度.Value
- strwh = strwh & " and month(申请时间)=" & Me.月度.Value
- strwh = strwh & " and 保全受理类型='" & Me.保全受理类型.Column(0, i) & "'"
- strwh = strwh & " and 审核员工号='" & Me.审核员工号.Column(0, j) & "'"
- n = Round(DCount("*", "日常数据", strwh) * Me.抽样比率.Value, 0)
- n = Int(DCount("*", "日常数据", strwh) * Me.抽样比率.Value) - (DCount("*", "日常数据", strwh) * Me.抽样比率.Value - Int(DCount("*", "日常数据", strwh) * Me.抽样比率.Value) > 0)
- If n > 0 Then
- ssql = "INSERT INTO 临时表 "
- ssql = ssql & "SELECT TOP " & n & " ID,*"
- ssql = ssql & " FROM 日常数据 "
- ssql = ssql & "WHERE " & strwh
- ssql = ssql & " ORDER BY Rnd([ID])"
- CurrentDb.Execute ssql
- End If
- Next
- Next
- Else
- MsgBox "请选择抽样查询年度、月度、抽样比率!"
- End If
- End Sub
复制代码 原件代码:加粗部分为改动部分。
Sub 抽样查询()
Dim ssql As String
Dim n As Long
Dim i As Long
Dim j As Long
Dim str As String
Dim strwh As String
If IsNull(Me.年度.Value) = False And IsNull(Me.月度.Value) = False And IsNull(Me.抽样比率.Value) = False Then
ssql = "DELETE * from 临时表"
CurrentDb.Execute ssql
str = "ID,申请序列号,机构名称,保单号,险种代码,变更类型,批单号,申请人身份证号,申请人姓名,代办人身份证号,代办人姓名,县区柜员工号,申请时间,给付方式,应付金额,转账账号,小额现金支付状态,保全受理类型,操作状态,审核员工号,审核时间"
For i = 0 To Me.保全受理类型.ListCount - 1
For j = 0 To Me.审核员工号.ListCount - 1
strwh = "year(申请时间)=" & Me.年度.Value
strwh = strwh & " and month(申请时间)=" & Me.月度.Value
strwh = strwh & " and 保全受理类型='" & Me.保全受理类型.Column(0, i) & "'"
strwh = strwh & " and 审核员工号='" & Me.审核员工号.Column(0, j) & "'"
n = Round(DCount("*", "日常数据", strwh) * Me.抽样比率.Value, 0)
n = Int(DCount("*", "日常数据", strwh) * Me.抽样比率.Value) - (DCount("*", "日常数据", strwh) * Me.抽样比率.Value - Int(DCount("*", "日常数据", strwh) * Me.抽样比率.Value) > 0)
If n > 0 Then
ssql = "INSERT INTO 临时表 ( " & str & " ) "
ssql = ssql & "SELECT TOP " & n & " " & str
ssql = ssql & " FROM 日常数据 "
ssql = ssql & "WHERE " & strwh
ssql = ssql & " ORDER BY Rnd([ID])"
CurrentDb.Execute ssql
End If
Next
Next
Else
MsgBox "请选择抽样查询年度、月度、抽样比率!"
End If
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|