【转载】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)
- 用Access连续窗体制作的树...(11.03)
- 【Access高效办公】上一年...(10.30)
- Access制作的RGB转CM...(09.22)
- Access制作的RGB调色板...(09.15)
- Access制作的快速车牌输入...(09.13)
- 【Access高效办公】统计当...(06.30)
- 【Access高效办公】用复选...(06.24)
- 根据变化的日期来自动编号的示例...(06.20)
- 【Access高效办公】按日期...(06.12)
学习心得
最新文章
- 用Access连续窗体制作的树菜单...(11.03)
- 【Access高效办公】上一年度累...(10.30)
- Access做的一个《中华经典论语...(10.25)
- Access快速开发平台--加载事...(10.20)
- 【Access有效性规则示例】两种...(10.10)
- EXCEL表格扫描枪数据录入智能处...(10.09)
- Access快速开发平台--多行文...(09.28)
- 关于从Excel导入长文本数据到A...(09.24)
- Access制作的RGB转CMYK...(09.22)
- 关于重装系统后Access开发的软...(09.17)


.gif)
