Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Sub NameControl(lblClicked As Label)
MsgBox (lblClicked.Name)
' Your code goes here to do whatever based on the label that was clicked
End Sub
Private Sub Label0_DblClick(Cancel As Integer)
Call NameControl(Me.Label0)
End Sub
Option Compare Database
Option Explicit
Private WithEvents mLabel As Access.Label
Private mRecordID As Long
Public Property Get RecordID() As Long
RecordID = mRecordID
End Property
Public Property Let RecordID(ByVal lngRecordID As Long)
mRecordID = lngRecordID
End Property
Public Property Get ClickLabel() As Access.Label
Set ClickLabel = mLabel
End Property
Public Property Set ClickLabel(ByVal lblClickLabel As Access.Label)
Set mLabel = lblClickLabel
mLabel.OnClick = "[Event Procedure]"
mLabel.OnMouseUp = "[Event Procedure]"
End Property
Private Sub mLabel_Click()
'run code here
MsgBox "You clicked label " & mLabel.Name
If mLabel.ForeColor = vbRed Then
mLabel.ForeColor = vbGreen
Else
mLabel.ForeColor = vbRed
End If
End Sub
Private Sub mLabel_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox "You moused up from " & mLabel.Name & "It is associated with record" & mRecordID
End Sub
Option Compare Database
Private click1 As New ClickLabel
Private click2 As New ClickLabel
Private click3 As New ClickLabel
Private click4 As New ClickLabel
Private click5 As New ClickLabel
Private Sub Form_Load()
Set click1.ClickLabel = Me.Label0
click1.RecordID = 1
Set click2.ClickLabel = Me.Label1
click2.RecordID = 2
Set click3.ClickLabel = Me.Label2
click3.RecordID = 3
Set click4.ClickLabel = Me.Label3
click4.RecordID = 4
Set click5.ClickLabel = Me.Label4
click5.RecordID = 5
End Sub
Public Function GetCommandCaption()
[COLOR=green]'Forms![frmLabelTest]!txtControlName.SetFocus
'Forms![frmLabelTest]!txtControlName.Text = ""[/color]
Forms![frmLabelTest]!cboTest1.Value = Screen.ActiveControl.Name
[COLOR=green]'Forms![frmLabelTest]!cboTest1.Value = Screen.ActiveControl.Caption[/color]
End Function
Public Function GetCommandCaption()
On Error GoTo ErrHandler
Dim sControlName As String
Dim sControlCaption As String
Dim sControlTag As String
sControlName = Screen.ActiveControl.Name
sControlCaption = Screen.ActiveControl.Caption
sControlTag = Screen.ActiveControl.Tag
Forms![frmLabelTest]!cboTest1.Value = sControlName
Forms![frmLabelTest]!txtControlName.SetFocus
Forms![frmLabelTest]!txtControlName.Text = sControlCaption
Exit Function
ErrHandler:
MsgBox "Error in Function GetCommandCaption. Error # " & Err.Number & ", " & Err.Description, vbOKOnly, "Error"
End Function