Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change font colour of dynamic text from a recordset

Status
Not open for further replies.

webstaff

Technical User
Jan 2, 2003
97
0
0
GB
Hi Guys,

Im a bit of a newbie to VBScript and wondered if someone could help me out.

I have some fields that are taken from a recordset on an ASP page.

If one of the fields has a value I want the other field to show in RED.

Im not realy sure how to do this??

This is what I want to say roughly


<%

If (Recordset1.Fields.Item("sire_title").Value)<> "" Then
(Recordset1.Fields.Item("sire_txt").Value).ForeColor = vbred
End If

%>



I realise my syntax will be way off, can anyone advise me here?
Regards as ever
Colin
 
Hello webstaff!

I'm not an ASP expert and I'm not sure what the rest of your code looks like, but I do know that you can't set a recordset field to a certain color. Whatever the field is on the screen that you are populating, set the color there instead.

You can pull a value from a recordset using this syntax:
Code:
strValue = Recordset1("sire_title")
If ASP is much like regular HTML and you have an ID assigned to your display field, you can change the field color using this syntax:
Code:
FieldID.Style.Color = RGB(255, 255, 255)

Good luck!
 
Thanks,
Im not sure quite what to do,
I tried this but still no Joy

<%

If (Recordset1.Fields.Item("sire_title").Value)<> "" Then
(Recordset1.Fields.Item("sire_txt").Value).Style.Color = RGB(255, 255, 255)
End If

%>

Thanks again
 
If your field ID is "sire_txt", try this:
Code:
sire_txt.Style.Color = RGB(255, 255, 255)
If "sire_txt" is not a field Id, then you'll have to qualify your field by something similer to this:
Code:
Document.[formname].sire_txt.Style.Color = RGB(255, 255, 255)
Like I mentioned previously, I'm not an ASP expert, so I'm not sure if the same rules apply for ASP as they do straight HTML. Someone who is an ASP expert may have a better answer for you!

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top