Option Explicit
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "j影片编号不能为空!", vbInformation + vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "影片名称不能为空!", vbInformation + vbOKOnly, "警告"
Text2.SetFocus
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "影片类别不能为空!", vbInformation + vbOKOnly, "警告"
Combo1.SetFocus
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "影片数量不能为空!", vbInformation + vbOKOnly, "警告"
Text4.SetFocus
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "影片价格不能为空!", vbInformation + vbOKOnly, "警告"
Text5.SetFocus
Exit Sub
End If
Set g_rs = g_db.OpenRecordset("select * from qbyd", dbOpenDynaset)
If g_rs.RecordCount > 0 Then
g_rs.MoveFirst
Do While Not g_rs.EOF
If g_rs!影片编号 = Text1.Text Then
MsgBox "对不起,该影片编号已经存在,请重新输入!", vbInformation + vbOKOnly, "警告"
Set g_rs = Nothing
Exit Sub
End If
g_rs.MoveNext
Loop
End If
g_rs.AddNew
g_rs!影片编号 = Text1.Text
g_rs!影片名称 = Text2.Text
g_rs!影片类别 = Mid(Combo1.Text, 1, 1)
g_rs!影片姓名 = Text4.Text
g_rs!影片价格 = Text5.Text
g_rs!入库日期 = DTPicker1.Value
g_rs!是否借出 = False
g_rs.Update
Text1.Text = ""
Text2.Text = ""
Text4.Text = ""
Text5.Text = ""
Set g_rs = Nothing
MsgBox "影片信息已成功添加!", vbInformation + vbOKOnly, "信息"
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
dbl
DTPicker1.Value = Date
Set g_rs = g_db.OpenRecordset("yplb", dbOpenTable)
Combo1.Clear
If g_rs.RecordCount > 0 Then
g_rs.MoveFirst
Do While Not g_rs.EOF
Combo1.AddItem g_rs!类别编号 + "-" + g_rs!影片类别
g_rs.MoveNext
Loop
Set g_rs = Nothing
Else
MsgBox "请先设置影片类别编号!", vbInformation + vbOKOnly, "警告"
影碟类别设置.Show
Unload Me
End If
End Sub
系统提示:
Set g_rs = g_db.OpenRecordset("yplb", dbOpenTable)
类型不匹配