ongke0711 > 24-05-22, 10:11 PM
Option Compare Database
Option Explicit
Private WithEvents mLabel As Access.Label
Private mName As String
Public Property Get Name() As String
Name = mLabel.Name
End Property
Public Property Get RoomLabel() As Access.Label
Set RoomLabel = mLabel
End Property
Public Property Set RoomLabel(TheLabel As Access.Label)
' On Error GoTo ErrHandler
Set mLabel = TheLabel
mLabel.OnClick = "[Event Procedure]"
Exit Property
ErrHandler:
If Not (Err.Number = 459 Or Err.Number = 91) Then
MsgBox ("Error: " & Err.Number _
& " " & Err.Description _
& " " & Err.Source)
End If
Resume Next
End Property
Private Sub mLabel_Click()
'MsgBox "Chon phong [" & mLabel.Tag & "]"
DoCmd.OpenForm "frmBooking", OpenArgs:=mLabel.Tag
End Sub
Option Compare Database
Option Explicit
Private mRoomLabels As New Collection
Public Function Add(TheLabel As Access.Control, ctlName As String) As RoomLabel
Dim newRoomLabel As RoomLabel
Set newRoomLabel = New RoomLabel
Set newRoomLabel.RoomLabel = TheLabel
mRoomLabels.Add newRoomLabel, ctlName
Set Add = newRoomLabel
End Function
Public Property Get count() As Integer
count = mRoomLabels.count
End Property
Public Property Get Item(ByVal index As Variant) As RoomLabel
Set Item = mRoomLabels(index)
End Property
Private Sub Class_Terminate()
Set mRoomLabels = Nothing
End Sub
Public Sub Clear()
Set mRoomLabels = New Collection
End Sub
Public Property Get Item_ByName(ByVal TheName As String) As RoomLabel
Dim Roomlbl As RoomLabel
For Each Roomlbl In mRoomLabels
If Roomlbl.Name = TheName Then
Set Item_ByName = Roomlbl
End If
Next
End Property