以下是引用haoooooooo在2006-1-24 13:56:00的发言:
[解释一下:
在窗体中ISSUESP input是我想用来完成输入数据的窗体。意向中是要每一个控件都是未绑定的,在输入信息后按按钮save把数据输入到表ISSUESP相应的字段中去,同时根据领料/退料/收货来更新表INVENTORY中相应备件的数量。
由于现在不能传附件了,所以将代码写在下面,把代码添加到保存按钮,同时去除窗体的记录源和文本框和组合框的控件来源属性,把窗体改为运行编辑。采用的是ADO,其它的东西可以依照这个来做。有些代码可能还需要些修改,但主要的是掌握方法。
Private Sub 保存记录_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
If IsNull(Me![SERINUM]) Then
MsgBox "请输入SERINUM"
Exit Sub
ElseIf IsNull(Me![SP No]) Then
MsgBox "请输入SP No"
Exit Sub
ElseIf IsNull(Me![REASON]) Then
MsgBox "请输入REASON"
Exit Sub
ElseIf IsNull(Me![QUANTITY]) Then
MsgBox "请输入QUANTITY"
Exit Sub
ElseIf IsNull(Me![ISSUEDATE]) Then
MsgBox "请输入ISSUEDATE"
Exit Sub
ElseIf IsNull(Me![ISSUETIME]) Then
MsgBox "请输入ISSUETIME"
Exit Sub
ElseIf IsNull(Me![SSO]) Then
MsgBox "请输入SSO"
Exit Sub
End If
Set cn = CurrentProject.Connection
rs.Open "ISSUESP", cn, adOpenKeyset, adLockPessimistic
With rs
.AddNew
.Fields("SERINUM") = Me![SERINUM]
.Fields("SP NO") = Me![SP No]
.Fields("REASON") = Me![REASON]
.Fields("QUANTITY") = Me![QUANTITY]
.Fields("ISSUEDATE") = Me![ISSUEDATE]
.Fields("ISSUETIME") = Me![ISSUETIME]
.Fields("SSO") = Me![SSO]
.Update
End With
rs.Close
MsgBox "保存成功!"
Me![SERINUM] = Null
Me![SP No] = Null
Me![REASON] = Null
Me![QUANTITY] = Null
Me![ISSUEDATE] = Null
Me![ISSUETIME] = Null
Me![SSO] = Null
End Sub
[此贴子已经被作者于2006-1-24 15:10:09编辑过]
|