N
New Guy
I have developed an Access Data Page (access2003) and I need to do
conditional formating in a page depending on the scores from the fields in X
table. I used the script from this MSDN article,
http://msdn2.microsoft.com/en-us/library/aa139969(office.10).aspx#odc_customizecontrols_cf
It works, BUT when there are Null values, I get a "Type mismatch 'Cint'"
error message. I know that this is because it cannot see the Null's as
integers (or so I think). The X table has tons of Null values and it is
supposed to have them. I have tried everything, researched all over the net,
and I cannot find an answer.
Here is my code:
<SCRIPT language=vbscript event=DataPageComplete(dscei) for=MSODSC>
<!--
' Highlight items according to their score.
dim sect
dim dscconst
dim bandHTML
' Check that the event fired for the DataPage in the GST Effects Table
GroupLevel.
If (dscei.DataPage.GroupLevel.RecordSource = "X Table") Then
Set dscconst = MSODSC.Constants
Set sect = dscei.DataPage.FirstSection
' Go through the sections of the event's DataPage object.
Do
' Ignore all sections except the header section.
If (sect.Type = dscconst.sectTypeHeader) Then
Set bandHTML = sect.HTMLContainer
' Change the text IN THE EFFECTS TABLE to
red/orange/yellow/green depending on Effects Assessment scale.
If (Cint(bandHTML.children("XValue").Innertext) <= 20) Then
bandHTML.children("WeightedValue").style.backgroundColor =
"red"
End If
If (Cint(bandHTML.children("XValue").Innertext) >= 21) Then
bandHTML.children("XValue").style.backgroundColor = "#ff9900"
End If
If (Cint(bandHTML.children("XValue").Innertext) >= 50) Then
bandHTML.children("XValue").style.backgroundColor = "#ffff33"
End If
If (Cint(bandHTML.children("XValue").Innertext) >= 75) Then
bandHTML.children("WeightedValue").style.backgroundColor =
"#339933"
End If
End If
Set sect = sect.NextSibling
Loop until (sect is nothing)
End If
-->
</SCRIPT>
I tried using: If
IsNull(bandHTML.children("XValue").Innertext) Then
bandHTML.children("XValue").style.backgroundColor = "#ffffff"
and it does not work, I also used .Value, and NOTHING... I have tried 10
types of combinations to get it to recognize the Nulls and I have not had
luck. I am relatively new at this, I would really appreciate your help!
New Guy
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/com...8535&dg=microsoft.public.access.modulesdaovba
conditional formating in a page depending on the scores from the fields in X
table. I used the script from this MSDN article,
http://msdn2.microsoft.com/en-us/library/aa139969(office.10).aspx#odc_customizecontrols_cf
It works, BUT when there are Null values, I get a "Type mismatch 'Cint'"
error message. I know that this is because it cannot see the Null's as
integers (or so I think). The X table has tons of Null values and it is
supposed to have them. I have tried everything, researched all over the net,
and I cannot find an answer.
Here is my code:
<SCRIPT language=vbscript event=DataPageComplete(dscei) for=MSODSC>
<!--
' Highlight items according to their score.
dim sect
dim dscconst
dim bandHTML
' Check that the event fired for the DataPage in the GST Effects Table
GroupLevel.
If (dscei.DataPage.GroupLevel.RecordSource = "X Table") Then
Set dscconst = MSODSC.Constants
Set sect = dscei.DataPage.FirstSection
' Go through the sections of the event's DataPage object.
Do
' Ignore all sections except the header section.
If (sect.Type = dscconst.sectTypeHeader) Then
Set bandHTML = sect.HTMLContainer
' Change the text IN THE EFFECTS TABLE to
red/orange/yellow/green depending on Effects Assessment scale.
If (Cint(bandHTML.children("XValue").Innertext) <= 20) Then
bandHTML.children("WeightedValue").style.backgroundColor =
"red"
End If
If (Cint(bandHTML.children("XValue").Innertext) >= 21) Then
bandHTML.children("XValue").style.backgroundColor = "#ff9900"
End If
If (Cint(bandHTML.children("XValue").Innertext) >= 50) Then
bandHTML.children("XValue").style.backgroundColor = "#ffff33"
End If
If (Cint(bandHTML.children("XValue").Innertext) >= 75) Then
bandHTML.children("WeightedValue").style.backgroundColor =
"#339933"
End If
End If
Set sect = sect.NextSibling
Loop until (sect is nothing)
End If
-->
</SCRIPT>
I tried using: If
IsNull(bandHTML.children("XValue").Innertext) Then
bandHTML.children("XValue").style.backgroundColor = "#ffffff"
and it does not work, I also used .Value, and NOTHING... I have tried 10
types of combinations to get it to recognize the Nulls and I have not had
luck. I am relatively new at this, I would really appreciate your help!
New Guy
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/com...8535&dg=microsoft.public.access.modulesdaovba