Changing Back Ground Colors when a field = Date() 
Author Message
 Changing Back Ground Colors when a field = Date()

Ok, I have a form which display all records in a table i continious view, so
I can see all the records at once. I am trying to get the backColor to
change when the date in a field is = to Date().

I am working off of something like this

 Dim db As Database
    Dim rs As Recordset
    Dim i As Integer

        Set db = DBEngine(0)(0)
        Set rs = db.OpenRecordset("Select * from tblPersonnel",
dbOpenDynaset)
        For i = 1 To 9 'the number of fields
            If DateDiff("d", rs("Qual_" & i), Date) = 0 Then
                Me!("Qual_" & i).BackColor = vbRed ' < < < =  =  = This is
where I think I am having problems
            Else
                Me!("Qual_" & i).BackColor = vbWhite '< < < =  =  = Here too
        End If
        Next
            Set rs = Nothing
            Set db = Nothing

Each field is ("Qual_" & "Next Applicable Number") Can someone help, I have
a headache fro this one, and it is probaably easy. Thank You



Wed, 22 May 2002 03:00:00 GMT  
 Changing Back Ground Colors when a field = Date()
Hi Matthew:

Is this giving you an error, or just not working as intended?
You may want to add a Me.Repaint at the end of the code.  I assume your
fields are named Qual_1, Qual_2, etc.?  I have a feeling the way you're
referencing your fields is the problem.  You might try looping the controls
like this:

dim c as Integer

    For c = 0 To Me.Count - 1
        If TypeOf Me(c) Is TextBox Then
            Me(c).BackColor = vbRed
        End If
    Next c

The TypeOf is not absolutely necessary, but will differentiate between
various control types.  Alternatively, you could do this to ensure that only
these 9 controls get colored:

    For c = 0 To Me.Count - 1
        If Left$(Me(c).Name, 4) = "Qual" Then
            Me(c).BackColor = vbRed
        End If
    Next c

For some more form-coloring code, check out the Chameleon utility at
http://www.personalpc.com/Developer/developer_download.htm.
--
Tom Oakes
Personal PC Consultants, Inc.

www.personalpc.com


Quote:
> Ok, I have a form which display all records in a table i continious view,
so
> I can see all the records at once. I am trying to get the backColor to
> change when the date in a field is = to Date().

> I am working off of something like this

>  Dim db As Database
>     Dim rs As Recordset
>     Dim i As Integer

>         Set db = DBEngine(0)(0)
>         Set rs = db.OpenRecordset("Select * from tblPersonnel",
> dbOpenDynaset)
>         For i = 1 To 9 'the number of fields
>             If DateDiff("d", rs("Qual_" & i), Date) = 0 Then
>                 Me!("Qual_" & i).BackColor = vbRed ' < < < =  =  = This is
> where I think I am having problems
>             Else
>                 Me!("Qual_" & i).BackColor = vbWhite '< < < =  =  = Here
too
>         End If
>         Next
>             Set rs = Nothing
>             Set db = Nothing

> Each field is ("Qual_" & "Next Applicable Number") Can someone help, I
have
> a headache fro this one, and it is probaably easy. Thank You



Fri, 26 Jul 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Setting Back ground Color for SSTAB control

2. Back ground Color

3. Changing a field's back color ?

4. Change BMP Back Color and Fore Color

5. How could I make a moving sprite that doesn't interfere with back ground

6. Please help on Back ground processing

7. Back Ground Colour for Treeview

8. Changing back ground color of treeview? how?

9. How to change SSTab 's back ground color?

10. Change TreeView ctl Back Color

11. FINALLY!! A way to change DTPicker back color

12. How to change back color in check box?

 

 
Powered by phpBB® Forum Software