选取录入高频使用词条
时 间:2007-12-06 08:35:10
作 者:UMVsoft整理 ID:8 城市:上海 QQ:2851379730
摘 要:对于某些词语,可能在录入时经常用到,它可能是字段值的其中某一部分,而不适宜于组合框或者列表框,用高频词条选区录入窗,可较好解决此问题。
正 文:
对于新手来说,此范例主要用到以下几个知识点:
1.全局的功能键定义。 见附件的 autokeys 宏
2.用Screen.ActiveCtontrol 来得到当前获得焦点的控件,而不必关心他所在窗体。
3.窗体之间的传值,实际上这里相当于控件之间的传值。
4.在文本框的光标处,插入字符。实际上是文本框SelStart和SelLength的应用。只有获得焦点的文本框才有此属性。
点击这里下载
主要功能代码预览:
' 定义公共变量
Public gctlInputCommonuseCalled As Control '调用窗体的控件
Public gintCtlCalledSelStart As Integer '当前光标位置
Public gintCtlCalledSellength As Integer '选取文本长度
'打开高频词选区窗体
Public Function gInputCommonUseString() As String
On Error Resume Next
Const cstrFormName = "frmpubselectIncommonuse"
Const cstrCtlName = "list0"
If Not CurrentProject.AllForms(cstrFormName).IsLoaded Then
'如果窗体是关闭的,那么打开窗体
Set gctlInputCommonuseCalled = Screen.ActiveControl '获取当前控件
If gctlInputCommonuseCalled Is Nothing Then
Exit Function
Else
'写入相关属性到变量
gintCtlCalledSelStart = gctlInputCommonuseCalled.SelStart
gintCtlCalledSellength = gctlInputCommonuseCalled.SelLength
'保存修改,否则可能插入错误值(就是控件的旧值)
DoCmd.RunCommand acCmdSaveRecord
'打开窗体
DoCmd.OpenForm cstrFormName
End If
Else
'否则,窗体是打开的,则返回窗体的值
If IsNull(gctlInputCommonuseCalled.Value) or gctlInputCommonuseCalled.ControlType <> acTextBox Then
'如果控件的值为空,这不是文本框,则直接赋值为选定的词条
gctlInputCommonuseCalled.Value = Forms(cstrFormName).Controls(cstrCtlName).Value
Else
'否则,在光标位置插入选定的词条
gctlInputCommonuseCalled.Value = Left$(gctlInputCommonuseCalled.Value, gintCtlCalledSelStart) & _
Forms(cstrFormName).Controls(cstrCtlName).Value & _
Mid$(gctlInputCommonuseCalled.Value, gintCtlCalledSellength + gintCtlCalledSelStart + 1)
End If
Err.Clear
'关闭窗体
DoCmd.Close acForm, cstrFormName
End If
End Function
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access选项卡示例】Ac...(09.09)
- 【Access源码示例】按输入...(09.02)
- 【Access日期区间段查询】...(08.29)
- 【Access日期区间段查询】...(08.27)
- Access怎样才能实现日期时...(08.21)
- 【Access定时打开查询】A...(08.19)
- Access生成固定数量的记录...(08.13)
- Access怎样才能实现日期时...(08.12)
- Access利用导航窗体控件对...(08.03)
学习心得
最新文章
- Access表中的字段名、字段标题...(09.19)
- Access快速开发平台--更改“...(09.18)
- 【中秋及国庆优惠】Access培训...(09.15)
- Access如何将日期型的数值转换...(09.14)
- 英文输入法输入数据中存在单引号引起...(09.11)
- 【Access选项卡示例】Acce...(09.09)
- 让Access光标停留在指定的控件...(09.07)
- 关于Access查询条件里使用通配...(09.06)
- Access报表偷懒制作法--Ac...(09.05)
- Access快速开发平台--窗体数...(09.04)