|
Private Sub 保存记录_Click()
On Error GoTo Err_保存记录_Click
'定义各种变量
Dim STemp As String
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
STemp = "Select * From 电"
'为打开数据表"查询语句"字符变量赋值
Rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'判断必填文本框和组合框是否为空
If IsNull(Me![ID]) = True Then
MsgBox "请输入ID它不能为空!", vbOKOnly, "输入ID"
Me![ID].SetFocus
ElseIf IsNull(Me![日期]) = True Then
MsgBox "请输入日期,它不能为空!", vbOKOnly, "输入日期"
Me![日期].SetFocus
ElseIf IsNull(Me![班次]) = True Then
MsgBox "请输入班次,它不能为空!", vbOKOnly, "输入班次"
Me![班次].SetFocus
ElseIf IsNull(Me![抄表人]) = True Then
MsgBox "请输入抄表人,它不能为空!", vbOKOnly, "输入抄表人"
Me![抄表人].SetFocus
ElseIf IsNull(Me![统计员]) = True Then
MsgBox "请输入统计员,它不能为空!", vbOKOnly, "输入统计员"
Me![统计员].SetFocus
Else
'保存产量输入
STemp = "INSERT INTO 电"
STemp = STemp & "(ID,日期,班次,抄表人,1#动力变,2#动力变,1#整流变,2#整流变,3#整流变,4#整流变,5#整流变,高压电机,统计员,备注)"
STemp = STemp & "VALUES ('" & Me![ID] & "','" & Me![日期] & "',"
STemp = STemp & "'" & Me![班次] & "','" & Me![1#动力变] & "',"
STemp = STemp & "'" & Me![2#动力变] & "','" & Me![1#整流变] & "',"
STemp = STemp & "'" & Me![2#整流变] & "','" & Me![3#整流变] & "',"
STemp = STemp & "'" & Me![4#整流变] & "','" & Me![5#整流变] & "',"
STemp = STemp & "'" & Me![高压电机] & "','" & Me![抄表人] & "',"
STemp = STemp & "'" & Me![统计员] & "','" & Me![备注] & "')"
DoCmd.RunSQL STemp
'刷新子窗体
Me![电 子窗体].Requery
End If
Exit_保存记录_Click:
Exit Sub
Err_保存记录_Click:
MsgBox Err.Description
Resume Exit_保存记录_Click
End Sub
[此贴子已经被作者于2007-2-2 15:53:27编辑过]
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|