|
本帖最后由 cocopig 于 2012-7-6 09:41 编辑
ACCESS设有窗体,有“年号”、“编号”和“后续编号”等文本框,通过保存按钮把“年号”、“编号”文本框中的数据用字符串相加后保存到数据表中“SVNum”字段中,“后续编号”保存到“SVFollowUp”字段中,每次新建记录时首先检查表中有没重复记录。我的代码如下:
(文本框“年号”=txtYear,“编号”=txtSVsn,“后续编号”=txtSVFollowUp)
................
Dim t1 As String
txtSVYear.SetFocus
t1 = txtSVYear.Text
Dim t2 As String
txtSVsn.SetFocus
t2 = txtSVsn.Text
Dim t3 As String
txtSVFollowUp.SetFocus
t3 = txtSVFollowUp.Text
Dim sqlstr As String '定义sql连接字符串
sqlstr = "select SVNum,SVFollowUp from InfoProject where SVNum = t1 + t2"
'检查“编号”是否重复
rs.Open sqlstr, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If rs.EOF Then
MsgBox "“编号”已分配,请重新输入!!"
Exit Sub
rs.Close
'Set rs = Nothing
Else
rs.Close
sqlstr = "select SVNum,SVFollowUp,District,ProjectName,ProjectAddress," _
& "StructureType,ConstructionArea,Cost,OvergruandStoery,UndergruandStoery," _
& "Status from InfoProject"
rs.Open sqlstr, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rs.AddNew '添加数据
.......................
运行程序提示上面斜体字代码中至少有一个参数未定义,我估计可能是连接字符串表达错了,请教各位我应该怎样修改???
|
|