I'm using VBA to apply Conditional Formatting in a report. I've created code to apply formatting to 31 fields called Date1, Date2, ...Date31 representing the 31 days of a month, for each person in a database. Each of the date fields are setup as strings, and can have up to seven different codes assigned, which will be indicated by different colors on the report using Conditional Format code.
I wrote a for/next loop to apply the conditional formatting to each of the Date(#) fields and it works great, if I only loop up to twelve times. If I loop thirteen times or more, the program errors out on different fields. Error meg: Run time error '438': Object doesn't support this property or method.
I coded each Date(#) field individually and again, after entering into the Date13 code, it errors.
Why does it stop after formatting 12 fields?
I tried to attach a piece of the code (I see there is a max of 20 lines) but new here and I don't know if I got it right.
I think I attach a file to show an example of a piece of the report output that works. I would appreciate anyone's help!
PS. I guess it would help if you would know what I am using. I am using Microsoft Access 2007 on Windows XP.
[IMGNOTHUMB]http://bytes.com/attachments/attachment/5517d1318521335/report-sample.jpg[/IMGNOTHUMB]
I wrote a for/next loop to apply the conditional formatting to each of the Date(#) fields and it works great, if I only loop up to twelve times. If I loop thirteen times or more, the program errors out on different fields. Error meg: Run time error '438': Object doesn't support this property or method.
I coded each Date(#) field individually and again, after entering into the Date13 code, it errors.
Why does it stop after formatting 12 fields?
I tried to attach a piece of the code (I see there is a max of 20 lines) but new here and I don't know if I got it right.
Code:
For x = 1 To 12
If Me("date" & x) = "LL" Or Me("date" & x) = "PA" Or Me("date" & x) = "PS" _
Or Me("date" & x) = "AS" Or Me("date" & x) = "P" Or Me("date" & x) = "A" Or Me("date" & x) = "S" Then
If Me("date" & x) = "LL" Then
Me("date" & x).BackColor = vbBlack
Me("date" & x).ForeColor = vbBlack
End If
If Me("date" & x) = "PA" Then
Me("date" & x).BackColor = vbCyan
Me("date" & x).ForeColor = vbCyan
End If
If Me("date" & x) = "PS" Then
Me("date" & x).BackColor = vbYellow
Me("date" & x).ForeColor = vbYellow
End If
' ...etc
PS. I guess it would help if you would know what I am using. I am using Microsoft Access 2007 on Windows XP.
[IMGNOTHUMB]http://bytes.com/attachments/attachment/5517d1318521335/report-sample.jpg[/IMGNOTHUMB]
Comment