新手求助
模块代码:Private Sub cmdEXIT_Click()
Unload Me
End Sub
Private Sub cmdSAVA_Click()
'数据校验~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'If txtopendate.Text = "" Then
'MsgBox "开户日期不能为空!", 48, "错误提示"
'txtopendate.SetFocus
'Exit Sub
'End If
'If txtcstname.Text = "" Then
'MsgBox "联系人不能为空!", 48, "错误提示"
'txtcstname.SetFocus
'Exit Sub
'End If
If txtYHDH.Text = "" And txtYHSJ.Text = "" Then
MsgBox "填写电话号码了吗?", 48, "错误提示"
txtYHDH.SetFocus
Exit Sub
End If
If txtZJXH.Text = "" Then
MsgBox "主机型号不能为空!", 48, "错误提示"
txtZJXH.SetFocus
Exit Sub
End If
If txtZJBH.Text = "" Then
MsgBox "主机编号不能为空!", 48, "错误提示"
txtZJBH.SetFocus
Exit Sub
End If
'添加数据~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Call OpenConn
sql = "select * from cstid"
rs.Open sql, cn, 3, 3
rs.AddNew
rs.Fields("id") = txtcstid.Text
rs.Fields("lxr") = txtcstname.Text
rs.Fields("pym") = txtPYM.Text
rs.Fields("yhlx") =
rs.Fields("yhdw") = txtYHDW.Text
rs.Fields("yhdz") = txtYHDZ.Text
rs.Fields("yzbm") = txtYZBM.Text
rs.Fields("yhdh") = txtYHDH.Text
rs.Fields("yhsj") = txtYHSJ.Text
rs.Fields("zjxh") = txtZJXH.Text
rs.Fields("zjbh") = txtZJBH.Text
rs.Fields("xsqxh") = txtXSQXH.Text
rs.Fields("xsqbh") = txtXSQBH.Text
rs.Fields("gjrq") = txtopendate.Text
rs.Fields("jdr") = txtoptor.Text
rs.Fields("bz") = txtBZ.Text
rs.Update
Call CloseConn
'保存结束~~~~~~~~~~~~~~~~~~~~~~~~~~~
'更新formZY listview~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FormZY.cmdcx = True
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
Call atnum
txtcstname.Text = ""
txtPYM.Text = ""
txtYHDW.Text = ""
txtYHDZ.Text = ""
txtYZBM.Text = ""
txtYHDH.Text = ""
txtYHSJ.Text = ""
txtZJXH.Text = ""
txtZJBH.Text = ""
txtXSQXH.Text = ""
txtXSQBH.Text = ""
txtopendate.Text = ""
txtBZ.Text = ""
"个人"
"单位"
txtZJBH.BackColor = &H80000005
End Sub
Private Sub Form_Load()
'添加下拉列表~~~~~~~~~~~~~~~~~
"家庭"
"机关"
"团体"
"经销商"
'自动编号~~~~~~~~~~~~~~
Call atnum
Me.Picture1.Picture = LoadPicture(App.Path & "\bg\bg3.bmp")
Me.Caption = sysname
Me.Icon = FormZY.Icon
txtoptor.Text = optor
End Sub
Private Sub txtopendate_LostFocus()
'~~~~~~~~~~日期格式~~~~~~~~~~~~~~~~
If IsDate(txtopendate.Text) Then
txtopendate = Format(txtopendate.Text, "yyyy-mm-dd")
Else
txtopendate = ""
End If
End Sub
Private Sub txtcstname_LostFocus()
'获得用户名拼音码~~~~~~~~~~~~~~~~~~~`
Dim a As Integer
txtPYM.Text = ""
a = Len(txtcstname.Text)
For i = 1 To a
txtPYM.Text = txtPYM.Text & py(Mid(txtcstname.Text, i, 1))
Next i
End Sub
Private Sub txtZJBH_Change()
'~~~~~~~~~~~~~验证文本有效性~~~~~~~~~~~~~~~~~~~~
If Len(txtZJBH.Text) = 16 Or Len(txtZJBH.Text) = 18 Then
txtZJBH.BackColor = &H80000005
Else
txtZJBH.BackColor = &H80C0FF
End If
End Sub
Private Sub txtZJBH_GotFocus()
'~~~~~~~~~~~~~验证文本有效性~~~~~~~~~~~~~~~~~~~~
If Len(txtZJBH.Text) = 16 Or Len(txtZJBH.Text) = 18 Then
txtZJBH.BackColor = &H80000005
Else
txtZJBH.BackColor = &H80C0FF
End If
End Sub
Private Sub atnum()
'自动编号~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Call OpenConn
sql = "select id from cstid ORDER BY id"
rs.Open sql, cn, 1, 1
If rs.RecordCount > 0 Then
rs.MoveLast
txtcstid.Text = "zy" & Format(Val(Right(rs.Fields("id"), 5) + 1), "0000")
Else
txtcstid.Text = "zy0001"
End If
Call CloseConn
End Sub
------------------------------------------
出错语句:txtcstid.Text = "zy" & Format(Val(Right(rs.Fields("id"), 5) + 1), "0000")
错误13:类型不匹配
请高手指教,在线等,谢谢