【Access高效办公】自动行号+插入行+删除行的源码示例分享
时 间:2022-06-08 11:12:09
作 者:鼠标 ID:27902 城市:嘉定
摘 要:自动行号+插入行+删除行。
正 文:
感谢盟威软件提供的Access学习平台,还有《半夜罗》Access爱好者提供的经典案例,因使用到了这个功能,在半夜罗Access爱好者的基础案例 http://www.accessoft.com/article-show.asp?id=18358 上,对《自动行号,插入行,删除行》做了一个包装,方便应用的时候调用,分享给有需要的Access爱好者,存个档也方便以后自己查资料。
演示图:
示例下载:
模块代码:
'--------------------------------------------------------- '插入一行-------------------------------------------- 'form插入行所指定的窗体 'ctl序号控件的名称 'tmptbl插入行窗体所绑定的临时表 Function insertRow(Form As Form, ctl As Control, tmptbable As String) On Error Resume Next If Form.Dirty Then Form.Dirty = False If ctl.Value > 0 Then tmpSN = ctl.Value strSQL = "update " & tmptbable & " set " & ctl.Name & " = " & ctl.Name & "+1 where " & ctl.Name & ">=" & tmpSN CurrentDb.Execute strSQL strSQL = "insert into " & tmptbable & "(" & ctl.Name & ") values(" & tmpSN & ")" CurrentDb.Execute strSQL Form.Requery Form.Recordset.Move tmpSN - 1 '光标定位 End If End Function '删除一行---------------------------------------------------- 'form插入行所指定的窗体 'ctl序号控件的名称 'tmptbl插入行窗体所绑定的临时表 Function deleteRow(Form As Form, ctl As Control, tmpTable As String) On Error Resume Next If Form.Dirty Then Form.Dirty = False If ctl.Value > 0 Then tmpSN = ctl.Value strSQL = "Delete * FROM " & tmpTable & " Where " & ctl.Name & "=" & tmpSN CurrentDb.Execute strSQL strSQL = "Update " & tmpTable & " SET " & ctl.Name & " = " & ctl.Name & "-1 Where " & ctl.Name & ">=" & tmpSN CurrentDb.Execute strSQL Form.Requery Form.Recordset.Move tmpSN - 1 '光标定位 End If End Function '------------------------------------------------------------------------- '新增数据行自动获取当前行号,放在子窗体的插入前事件中 Function getRow(Form As Form, ctl As Control) ctl.Value = Form.CurrentRecord End Function
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- Inputbox输入密码打开查...(12.23)
- 【Access Dsum示例】...(12.16)
- Inputbox输入密码打开窗...(12.13)
- 【Access DCount示...(12.02)
![](images/weixin.jpg)
学习心得
最新文章
- 用Access查询语句如何得到前3...(02.17)
- Access快速开发平台--导入导...(02.14)
- 按回车键后光标移动到下一条记录的V...(02.12)
- Access快速开发平台--要实现...(02.10)
- Access快速开发平台--让Pe...(02.08)
- 【Access Dsum示例】用D...(02.07)
- Access对子窗体的数据进行平均...(02.05)
- Access快速开发平台附件上传,...(01.18)
- 【IIF函数示例】用iif函数判断...(01.18)
- Access快速开发平台--如何获...(01.17)