|
請教各位高手,我的代碼到底哪里錯了,謝謝!好像昨天還能用,今天就不行了,不知道怎麼回事.
我是想從廠內呆滯品尺寸表中選出符合客戶現用機种尺寸表中在公差範圍內的記錄來
繁體+access2000的
Dim a, b, c, d As Single
Dim cn As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim rs3 As New ADODB.Recordset
Set cn = CurrentProject.Connection
rs1.Open "客戶現用機种尺寸表", cn, 3, 3
rs2.Open "廠內呆滯品尺寸表", cn, 3, 3
rs3.Open "結果表", cn, 3, 3
If IsNull(Me.Text1) = True Then
MsgBox "請輸入一個客戶現用的機种名!", vbOKOnly, "系統提示"
Me.Text1.SetFocus
End
End If
If IsNull(DLookup("品名", "客戶現用機种尺寸表", "品名='" & Me.Text1 & "'")) Then
MsgBox "您輸入了一個不存在的機种名!", vbOKOnly, "錯誤"
Me.Text1 = Null
Me.Text1.SetFocus
End
End If
DoCmd.SetWarnings False
DoCmd.OpenQuery "清空結果表"
DoCmd.SetWarnings True
Me.結果表子表單.Requery
Me.Text3 = DLookup("客戶", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text5 = DLookup("中徑", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text7 = DLookup("外徑", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text9 = DLookup("中柱高", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text11 = DLookup("板厚", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text13 = DLookup("中孔", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text15 = DLookup("攻牙", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text17 = DLookup("溝槽", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text19 = DLookup("背凸", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
Me.Text21 = DLookup("柱凹", "客戶現用機种尺寸表", "品名='" & Forms![表單1].Text1 & "'")
a = Me.Text5
b = Me.Text7
c = Me.Text9
d = Me.Text11
Do While Not rs2.EOF
If rs2!中徑 > a + 0.05 Or rs2!中徑 < a - 0.15 Then
End
Else
If rs2!外徑 > b + 15 Or rs2!外徑 < b - 4.5 Then
End
Else
If rs2!中柱高 > c + 0.6 Or rs2!中柱高 < c - 0.25 Then
End
Else
If rs2!板厚 > d + 1.7 Or rs2!板厚 < d - 0.7 Then
End
Else
rs3.AddNew
rs3!品名 = rs2!品名
rs3!客戶 = rs2!客戶
rs3!中徑 = rs2!中徑
rs3!外徑 = rs2!外徑
rs3!中柱高 = rs2!中柱高
rs3!板厚 = rs2!板厚
rs3!中孔 = rs2!中孔
rs3!攻牙 = rs2!攻牙
rs3!溝槽 = rs2!溝槽
rs3!背凸 = rs2!背凸
rs3!柱凹 = rs2!柱凹
rs3.Update
rs2.MoveNext
End If
End If
End If
End If
Loop
rs1.Close
rs2.Close
rs3.Close
cn.Close
Set cn = Nothing
Me.結果表子表單.Requery
End Sub
[此贴子已经被作者于2007-6-6 9:29:24编辑过]
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|