我正在使用 Vb6 和 Access 2007。我正在将记录添加到来自 vb6 的访问表名称“主题代码”。主题代码表的详细信息如下。
Subjectcode 表:标题(Degree,Branch,Year1,Year2,Semester,Subjectcode,Subjectname,Theory_Practical, Major_Allied_Elective)值(Bsc,computerscience,2001,2004,1,RACS1,Vb6 programming,Theory,Major)
注意:上表中的主键是 Degree,Branch,Year1,Year2,Semester,Subjectcode 我用来从 vb6 向访问表添加条目的代码如下:
If degree = "" Or branch1 = "" Or year1 = "" Or year2 = "" Or semester = "" Or subcode.Text = "" Or subname.Text = "" Or theory.Text = "" Or major.Text = "" Then
MsgBox "Fields can't be empty ! All are mandatory!"
Else
rs.Open "select * from subjectcode", con, 1, 3
rs.AddNew
rs!degree = degree
rs!branch = branch1
rs!year1 = year1
rs!year2 = year2
rs!semester = semester
rs!Subjectcode = subcode.Text
rs!Subjectname = subname.Text
rs!Theory_Practical = theory.Text
rs!Major_Allied_Elective = major.Text
rs.Update
MsgBox "Successfully Saved !", vbOKOnly + vbInformation, "info"
rs.Close
End If
而vb6的那个添加形式的截图在这里:http://tinypic.com/r/w7c7if/6 不存在相同条目时添加记录。如果记录已经存在,它应该说“记录已经存在”,我不知道该怎么做。请各位大神给个思路。