|
2#
楼主 |
发表于 2006-5-17 18:38:00
|
只看该作者
Private Sub 修改_Click()
On Error GoTo Err_修改_Click
Dim i As Integer
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![网点编号]) = True Then
MsgBox "请输入'网点编号',它不可以为空!", vbOKOnly, "输入'网点编号'"
Me![网点编号].SetFocus
Exit Sub
ElseIf IsNull(Me![客户经理编号]) = True Then
MsgBox "请输入'客户经理编号',它不可以为空!", vbOKOnly, "输入'客户经理编号'"
Me![客户经理编号].SetFocus
Exit Sub
ElseIf IsNull(Me![名称]) = True Then
MsgBox "请输入'名称',它不可以为空!", vbOKOnly, "输入'名称'"
Me![名称].SetFocus
Exit Sub
ElseIf IsNull(Me![客户号]) = True Then
MsgBox "请输入'客户号',它不可以为空!", vbOKOnly, "输入'客户号'"
Me![客户号].SetFocus
Exit Sub
ElseIf IsNull(Me![法人代码]) = True Then
MsgBox "请输入'法人代码',它不可以为空!", vbOKOnly, "输入'法人代码'"
Me![法人代码].SetFocus
Exit Sub
ElseIf IsNull(Me![帐号]) = True Then
MsgBox "请输入'帐号',它不可以为空!", vbOKOnly, "输入'帐号'"
Me![帐号].SetFocus
Exit Sub
ElseIf IsNull(Me![优惠系数]) = True Then
MsgBox "请输入'帐号',它不可以为空!", vbOKOnly, "输入'优惠系数'"
Me![优惠系数].SetFocus
Exit Sub
Else
If Rs.RecordCount < 1 Then
Exit Sub
End If
Rs.MoveFirst
For i = 1 To Rs.RecordCount
If Rs("帐号") = Me![企业资料 子窗体]![帐号] Then
Rs("网点编号") = Me![企业资料 子窗体]![网点编号]
Rs("客户经理编号") = Me![企业资料 子窗体]![客户经理编号]
Rs("名称") = Me![企业资料 子窗体]![名称]
Rs("客户号") = Me![企业资料 子窗体]![客户号]
Rs("法人代码") = Me![企业资料 子窗体]![法人代码]
Rs("优惠系数") = Me![企业资料 子窗体]![优惠系数]
Rs.Update
Me![企业资料 子窗体].Requery
MsgBox "档案已经修改完成!", vbOKOnly, "修改完成"
Exit Sub
Else
Rs.MoveNext
End If
Next i
End If
Set Rs = Nothing
Exit_修改_Click:
Set Rs = Nothing
Exit Sub
Err_修改_Click:
MsgBox Err.Description
Resume Exit_修改_Click
End Sub
修改后为何不会把新的记录保存?? |
|