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里该怎么写那个代码,谢谢大家
展开
 我来答
bin__32
2008-08-02 · 超过21用户采纳过TA的回答
知道答主
回答量:274
采纳率:0%
帮助的人:0
展开全部
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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式