猿问

这个是我的代码,但是在运行的时候说缺少函数或者变量,我是想要添加一个东西到数据库的表里面?

Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Text10.Text = "" Or Text11.Text = "" Or Text12.Text = "" Or Text13.Text = "" Or Text14.Text = "" Or Text15.Text = "" Or Text16.Text = "" Then
MsgBox "填写的信息不完整", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
With Datal
Recordset.AddNew
Recordset.Fields("款号") = Text1.Text
Recordset.Fields("品号") = Text2.Text
Recordset.Fields("颜色") = Text3.Text
Recordset.Fields("色号") = Text4.Text
Recordset.Fields("S") = Text5.Text
Recordset.Fields("M") = Text6.Text
Recordset.Fields("L") = Text7.Text
Recordset.Fields("XL") = Text8.Text
Recordset.Fields("XXL") = Text9.Text
Recordset.Fields("XXL") = Text11.Text
Recordset.Fields("库存数") = Text12.Text
Recordset.Fields("价格") = Text13.Text
Recordset.Fields("分类") = Text14.Text
Recordset.Fields("面料") = Text15.Text
Recordset.Fields("季节") = Text16.Text
Recordset.Fields("年份") = Text10.Text
Datal Refresh
Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Text10.Text = "" Or Text11.Text = "" Or Text12.Text = "" Or Text13.Text = "" Or Text14.Text = "" Or Text15.Text = "" Or Text16.Text = ""
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub

烙印99
浏览 214回答 2
2回答

回首忆惘然

Recordset 是Datal 的一个属性,所以你的 with 块里应该这么写:.Recordset.AddNew.Recordset.Fields("款号") = Text1.Text另外,with 块需要 End With 来结尾

吃鸡游戏

Private Sub GCD(ByRef m As Long, ByRef n As Long)问题出在这里!你调用n1 = GCD(m1, n1)需要有返回值,sub是没有返回值的,应该是Private function GCD(ByRef m As Long, ByRef n As Long),另外在GSD里要用GCD=返回值才可以!
随时随地看视频慕课网APP
我要回答