I have a form that when a IID is entered into a txtbox - the "After update" runs a couple of MakeTable Queries and populates several txtboxes on the form - you can then click on a color coded legend (box) - and if the name of the label=the value in a table - the label changes to a predetermined color.
Is there a way to have code loop thru all the labels and if it sees a certain color to concatenate the label names and save them in a different table along with all the other txtboxes on the form? From a command button????
Something like red forecolor label names would be values in a field, green forecolor labels would be values in a field, blue forecolor would be a field, etc...
Here is an example of the code that loops thru the labels and if it finds a match to change the color.
Perhaps this can help??
Private Sub Box248_Click()
Dim rstAllocatedIID As New ADODB.Recordset
Dim ctl As Control
Dim I As Integer
' Open a recordset based on the WWReviewhelper query.
rstAllocatedIID.Open "qryAllocatedIID", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no allocations are set.
If rstAllocatedIID.RecordCount = 0 Then
MsgBox "There are no Allocations set on this part."
End If
If rstAllocatedIID.EOF Then
Exit Sub
End If
'loop through form controls
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
With rstAllocatedIID
.MoveFirst
For I = 1 To .RecordCount
If ctrl.Caption = !GTWY Then
ctrl.ForeColor = 16711935
End If
.MoveNext
Next I
End With
End If
Next
End Sub
Is there a way to have code loop thru all the labels and if it sees a certain color to concatenate the label names and save them in a different table along with all the other txtboxes on the form? From a command button????
Something like red forecolor label names would be values in a field, green forecolor labels would be values in a field, blue forecolor would be a field, etc...
Here is an example of the code that loops thru the labels and if it finds a match to change the color.
Perhaps this can help??
Private Sub Box248_Click()
Dim rstAllocatedIID As New ADODB.Recordset
Dim ctl As Control
Dim I As Integer
' Open a recordset based on the WWReviewhelper query.
rstAllocatedIID.Open "qryAllocatedIID", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no allocations are set.
If rstAllocatedIID.RecordCount = 0 Then
MsgBox "There are no Allocations set on this part."
End If
If rstAllocatedIID.EOF Then
Exit Sub
End If
'loop through form controls
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
With rstAllocatedIID
.MoveFirst
For I = 1 To .RecordCount
If ctrl.Caption = !GTWY Then
ctrl.ForeColor = 16711935
End If
.MoveNext
Next I
End With
End If
Next
End Sub