|
你的标题不对呢,我修改了一下,cuxun
请问一下,我没有用ADO来进行添加,但是我这个是可以做到添加的,这个有没有什么问题?
Private Sub Cmd_Save_Click()
On Error GoTo Err_Cmd_Save_Click
Dim i As Integer
Dim STemp As String
'判断“公司简称”等文本框是否为空
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
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
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
STemp = "INSERT INTO 客户信息"
STemp = STemp & "(公司id,公司简称,公司名称,电话,分机,传真,邮箱,地址,邮编,联系人,手机,部门,职务,生日,客户区域,客户类型,客户状态,客户行业,签约日期,续约日期,收款周期,收款方式,租赁金额,养护周期,业务人员,养护人员,开户银行,银行账号,附注)"
STemp = STemp & "VALUES ('" & Me![公司ID] & "','" & Me![公司简称] & "',"
STemp = STemp & "'" & Me![公司名称] & "','" & Me![电话] & "',"
STemp = STemp & "'" & Me![分机] & "','" & Me![传真] & "',"
STemp = STemp & "'" & Me![邮箱] & "','" & Me![地址] & "',"
STemp = STemp & "'" & Me![邮编] & "','" & Me![联系人] & "',"
STemp = STemp & "'" & Me![手机] & "','" & Me![部门] & "',"
STemp = STemp & "'" & Me![职务] & "','" & Me![生日] & "',"
STemp = STemp & "'" & Me![客户区域] & "','" & Me![客户类型] & "',"
STemp = STemp & "'" & Me![客户状态] & "','" & Me![客户行业] & "',"
STemp = STemp & "'" & Me![签约日期] & "','" & Me![续约日期] & "',"
STemp = STemp & "'" & Me![收款周期] & "','" & Me![收款方式] & "',"
STemp = STemp & "'" & Me![租赁金额] & "','" & Me![养护周期] & "',"
STemp = STemp & "'" & Me![业务人员] & "','" & Me![养护人员] & "',"
STemp = STemp & "'" & Me![开户银行] & "','" & Me![银行账号] & "',"
STemp = STemp & "'" & Me![附注] & "')"
'使用DoCmd对象的RunSQL方法执行查询
DoCmd.RunSQL STemp
Me![公司ID] = "KH" & Format(Val(Right(Nz(DMax("[公司ID]", "客户信息", ""), 0), 3)) + 1, "000")
Me![公司简称] = Null
Me![公司名称] = Null
Me![电话] = Null
Me![分机] = Null
Me![传真] = Null
Me![邮箱] = Null
Me![地址] = Null
Me![邮编] = Null
Me![联系人] = Null
Me![手机] = Null
Me![部门] = Null
Me![职务] = Null
Me![生日] = Null
Me![客户区域] = Null
Me![客户类型] = Null
Me![客户状态] = Null
Me![客户行业] = Null
Me![签约日期] = Null
Me![续约日期] = Null
Me![收款周期] = Null
Me![收款方式] = Null
Me![租赁金额] = Null
Me![养护周期] = Null
Me![业务人员] = Null
Me![养护人员] = Null
Me![开户银行] = Null
Me![银行账号] = Null
Me![附注] = Null
Me![公司简称].SetFocus
Forms![主页]![Cmb_Text].Requery
End If
Exit_Cmd_Save_Click:
Set Rs = Nothing
Exit Sub
Err_Cmd_Save_Click:
MsgBox Err.Description
Resume Exit_Cmd_Save_Click
End Sub
[ 本帖最后由 cuxun 于 2007-12-5 19:47 编辑 ]
[ 本帖最后由 cuxun 于 2007-12-12 07:35 编辑 ] |
|