
VB连接ACCESS要执行一条查询 25
我使用VB和ACCESS连接,使用的是DATA控件想要在添加新记录时自动生成编号,以下是我的代码PrivateSubCommand1_Click()DimstrAsStr...
我使用VB和ACCESS连接,使用的是DATA控件
想要在添加新记录时自动生成编号,以下是我的代码
Private Sub Command1_Click()
Dim str As String (重点看这里)
str = "select max(no) from tel" (重点看这里)
If Command1.Caption = "添 加" Then
Command1.Caption = "确 定"
Data1.Recordset.AddNew
Data1.Database.Execute str (重点看这里)
Text1.SetFocus
Else
Command1.Caption = "添 加"
Data1.Recordset.Update
MsgBox ("添加成功!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Combo1.Text = ""
Text2.SetFocus
End If
End Sub
我想把上面那条查询语句的结果+1,显示在TEXTBOX里该怎么写那个代码,谢谢大家 展开
想要在添加新记录时自动生成编号,以下是我的代码
Private Sub Command1_Click()
Dim str As String (重点看这里)
str = "select max(no) from tel" (重点看这里)
If Command1.Caption = "添 加" Then
Command1.Caption = "确 定"
Data1.Recordset.AddNew
Data1.Database.Execute str (重点看这里)
Text1.SetFocus
Else
Command1.Caption = "添 加"
Data1.Recordset.Update
MsgBox ("添加成功!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Combo1.Text = ""
Text2.SetFocus
End If
End Sub
我想把上面那条查询语句的结果+1,显示在TEXTBOX里该怎么写那个代码,谢谢大家 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim str As String (重点看这里)
str = "select max(no) from tel" (重点看这里)
If Command1.Caption = "添 加" Then
Command1.Caption = "确 定"
Data1.Recordset.AddNew
Data1.Database.Execute str (重点看这里)
Text1.SetFocus
Else
Command1.Caption = "添 加"
Data1.Recordset.Update
MsgBox ("添加成功!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Combo1.Text = ""
Text2.SetFocus
End If
End Sub
+1
Dim str As String (重点看这里)
str = "select max(no) from tel" (重点看这里)
If Command1.Caption = "添 加" Then
Command1.Caption = "确 定"
Data1.Recordset.AddNew
Data1.Database.Execute str (重点看这里)
Text1.SetFocus
Else
Command1.Caption = "添 加"
Data1.Recordset.Update
MsgBox ("添加成功!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Combo1.Text = ""
Text2.SetFocus
End If
End Sub
+1
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询