Hi there
I am trying to use combox with selection the right label.
When I select a name from the combobox called "choose" I would like to change the colour just the label where record is assinged to. When I select lets say name1 then the label nr1 is colored.
THis what I have is changing me all labels
I am trying to use combox with selection the right label.
When I select a name from the combobox called "choose" I would like to change the colour just the label where record is assinged to. When I select lets say name1 then the label nr1 is colored.
THis what I have is changing me all labels
Code:
Private Sub choose_AfterUpdate()
Dim lbl As Access.Control
Dim msg, title, response
Dim criteria As String
criteria = "id_tomb =" & Me.choose.Value
MsgBox (criteria)
msg = "Wpis nieodnaleziony"
title = "ATTENTION!!!!!"
For Each lbl In Me.Controls 'dla każdej zmiennej w zestawie kotrolek tego formualrza
If TypeOf lbl Is Label Then
lbl.OnClick = "=LabelClick(" & Mid(lbl.Name, Len(LABEL_PREFIX) + 1) & ")"
End If
Next
With Me.RecordsetClone
.MoveFirst
.FindFirst criteria
If idx >= 1 Then
If lColour >= 1 Then
If Not Me(LABEL_PREFIX & idx).BackColor = lColour Then Me(LABEL_PREFIX & idx).BackColor = lColour
If Not Me(LABEL_PREFIX & idx).BackStyle = 1 Then Me(LABEL_PREFIX & idx).BackStyle = 1
Else
If Not Me(LABEL_PREFIX & idx).BackStyle = 0 Then Me(LABEL_PREFIX & idx).BackStyle = 0
Me(LABEL_PREFIX & idx).BackStyle = 0
End If
Call LblClickGoToRecord(idx) 'wywołanie funkcji gotorecord
Else
For Each lbl In Me.Controls
If lbl.ControlType = acLabel Then
If lColour >= 0 Then
If Not lbl.BackColor = lColour Then lbl.BackColor = lColour
If Not lbl.BackStyle = 1 Then lbl.BackStyle = 1
Else
If Not lbl.BackStyle = 0 Then lbl.BackStyle = 0
End If
End If
Next
End If
If .NoMatch Then
Beep
response = MsgBox(msg, vbOKOnly, title)
Else
Me.Bookmark = .Bookmark
End If
End With
''GoTo Finish
''Errhand1:
''MsgBox Err.Number & " " & Err.Description
''Resume Next
End Sub