Hi there,
I've been searching the net & the forums here over the last few days for help with my problem & am getting myself really confused.. hoping someone may be able to help me here.
I've got a continuous form which has 6 textboxes in each row, one of which contains the name of an Assessor, who (in another table) will have a particular colour assigned for him/her.
What I'm trying to do is loop through the records of the continuous form, get the colour value for the Assessor for that record, & then change the background colour of all textboxes in that record to that colour. (I hope that makes sense)
I've been messing around trying to do this with Recordset clones, then trying Me.Controls instead.. but so far no luck. (I am very foggy on whether I should be using a Recordset or directly working with the controls on the form..?)
Here's what I've got at the moment (but I keep changing it, so this is kinda muddled):
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim lngColour As Long
Dim ctl As Control
Set rs = Me.RecordsetClo ne
rs.MoveFirst
Do While Not rs.EOF
If Not IsNull(rs.Field s("AssessorName ")) Then
lngColour = DLookup("[AssessorColour]", "Assessors" , "[AssessorName]='" & rs.Fields("Asse ssorName").Valu e & "'")
' the following doesn't work...
'
For Each fld In rs.Fields
fld.Properties( "BackColor").Va lue = lngColor
Next
' following doesn't work either -- it changes all textboxes on
' the whole form to lngColour! (permanently, for some weird reason?!)
' How do I just loop through the controls in 1 record?
'
' For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Then
' ctl.BackColor = lngColour
' End If
' Next ctl
End If
rs.MoveNext
Loop
So there are 2 kinda separate ideas there, neither right, & I really don't know if I'm even on the right track.. any help appreciated!
Thanks in advance,
Karen
I've been searching the net & the forums here over the last few days for help with my problem & am getting myself really confused.. hoping someone may be able to help me here.
I've got a continuous form which has 6 textboxes in each row, one of which contains the name of an Assessor, who (in another table) will have a particular colour assigned for him/her.
What I'm trying to do is loop through the records of the continuous form, get the colour value for the Assessor for that record, & then change the background colour of all textboxes in that record to that colour. (I hope that makes sense)
I've been messing around trying to do this with Recordset clones, then trying Me.Controls instead.. but so far no luck. (I am very foggy on whether I should be using a Recordset or directly working with the controls on the form..?)
Here's what I've got at the moment (but I keep changing it, so this is kinda muddled):
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim lngColour As Long
Dim ctl As Control
Set rs = Me.RecordsetClo ne
rs.MoveFirst
Do While Not rs.EOF
If Not IsNull(rs.Field s("AssessorName ")) Then
lngColour = DLookup("[AssessorColour]", "Assessors" , "[AssessorName]='" & rs.Fields("Asse ssorName").Valu e & "'")
' the following doesn't work...
'
For Each fld In rs.Fields
fld.Properties( "BackColor").Va lue = lngColor
Next
' following doesn't work either -- it changes all textboxes on
' the whole form to lngColour! (permanently, for some weird reason?!)
' How do I just loop through the controls in 1 record?
'
' For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Then
' ctl.BackColor = lngColour
' End If
' Next ctl
End If
rs.MoveNext
Loop
So there are 2 kinda separate ideas there, neither right, & I really don't know if I'm even on the right track.. any help appreciated!
Thanks in advance,
Karen
Comment