【转载】VBA-通过标签确定关联控件
时 间:2023-04-04 10:51:32
作 者:金宇 ID:43 城市:江阴
摘 要:VBA-通过标签确定关联控件。
正 文:
下面是一个函数,我们可以通过标签来确定与哪个控件相关联,使用的时候先将下面函数放到模块中。
'------------------------------------------------------------------------ ' Procedure : GetLabelAssoCtrl ' Author : Daniel Pineault, CARDA Consultants Inc. ' Website : http://www.cardaconsultants.com ' Req'd Refs: Late Binding -> none required ' ' Input Variables: ' ~~~~~~~~~~~~~~~~ ' oLbl : Label object to retrieve the associated control name of ' oFrm : Form object containing the label control ' ' Return: ' ~~~~~~~ ' The function return the name of the associated control, and "" if it isn't associated ' with any control. ' ' Usage: ' ~~~~~~ ' GetLabelAssoCtrl(me.lbl_FirstName, me) ' Returns -> txt_FirstName ' ' Revision History: ' Rev Date(yyyy-mm-dd) Description ' ************************************************************** ' 1 2023-03-31 '---------------------------------------------------------------- Function GetLabelAssoCtrl(oLbl As Access.Label, oFrm As Access.Form) As String On Error GoTo Error_Handler Dim sAssoCtrl As String sAssoCtrl = oLbl.Parent.Name If oFrm.Name = sAssoCtrl Then sAssoCtrl = "" GetLabelAssoCtrl = sAssoCtrl Error_Handler_Exit: On Error Resume Next Exit Function Error_Handler: MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _ "Error Source: GetLabelAssoCtrl" & vbCrLf & _ "Error Number: " & Err.Number & vbCrLf & _ "Error Description: " & Err.Description & _ Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _ , vbOKOnly + vbCritical, "An Error has Occurred!" Resume Error_Handler_Exit End Function
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- 仓库管理实战课程(8)-商品信息功...(04.01)
- 仓库管理实战课程(7)-链接表(03.31)
- 仓库管理实战课程(6)-创建查询(03.29)
- 仓库管理实战课程(5)-字段属性(03.27)
- 设备装配出入库管理系统;基于Acc...(03.24)
- 仓库管理实战课程(4)-建表操作(03.22)
- 仓库管理实战课程(3)-需求设计说...(03.19)
- 仓库管理实战课程(2)-软件背景和...(03.18)
- 仓库管理实战课程(1)-讲师介绍(03.16)
- 统计当月之前(不含当月)的记录数怎...(03.11)