mark curtis
Registered User.
- Local time
- Today, 08:01
- Joined
- Oct 9, 2000
- Messages
- 457
Hi folks,
i have created a string variable called strRAG which is a combination of text "Me!lbl" and another variable called intSiteID, which forms for example lable name Me!lbl51. What i want to do is then use this string to set the BackColor of the label using the below, where lngRAG is another variable (RGB Color).
I'm not sure if i need to create an object or not so any help as always much appreciated.
strRAG.BackColor = lngRAG
--------------------------------------------
the full code i am using is below:
For i = 1 To 3
If i = 1 Then
strRAGCol = "Red"
lngRAG = RGB(255, 0, 0)
ElseIf i = 2 Then
strRAGCol = "Amber"
lngRAG = RGB(258, 223, 27)
Else
strRAGCol = "Green"
lngRAG = RGB(0, 255, 0)
End If
strSQL = "SELECT tblSite.SiteID, tblSite.SiteRAG, tblSite.Active " _
& " FROM tblSite " _
& " WHERE (((tblSite.Active)=Yes)AND((tblSite.SiteRAG)= '" & strRAGCol & "'));"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
intRecordCount = 0
rs.MoveFirst
intID = rs.Fields("SiteID").Value
strRAG = "Me!lbl" & intID
Do Until rs.EOF
strRAG.BackColor = lngRAG
rs.MoveNext
intRecordCount = intRecordCount + 1
Loop
Next i
rs.Close
db.Close
End Sub
i have created a string variable called strRAG which is a combination of text "Me!lbl" and another variable called intSiteID, which forms for example lable name Me!lbl51. What i want to do is then use this string to set the BackColor of the label using the below, where lngRAG is another variable (RGB Color).
I'm not sure if i need to create an object or not so any help as always much appreciated.
strRAG.BackColor = lngRAG
--------------------------------------------
the full code i am using is below:
For i = 1 To 3
If i = 1 Then
strRAGCol = "Red"
lngRAG = RGB(255, 0, 0)
ElseIf i = 2 Then
strRAGCol = "Amber"
lngRAG = RGB(258, 223, 27)
Else
strRAGCol = "Green"
lngRAG = RGB(0, 255, 0)
End If
strSQL = "SELECT tblSite.SiteID, tblSite.SiteRAG, tblSite.Active " _
& " FROM tblSite " _
& " WHERE (((tblSite.Active)=Yes)AND((tblSite.SiteRAG)= '" & strRAGCol & "'));"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
intRecordCount = 0
rs.MoveFirst
intID = rs.Fields("SiteID").Value
strRAG = "Me!lbl" & intID
Do Until rs.EOF
strRAG.BackColor = lngRAG
rs.MoveNext
intRecordCount = intRecordCount + 1
Loop
Next i
rs.Close
db.Close
End Sub