Case Select

  • Thread starter Secret Squirrel
  • Start date
S

Secret Squirrel

I'm using the following case select to change the backcolor of some controls
on my report. My question is how can I use just the first character in my
case selects? I'm going to modify my strCaption but the first value will
still be the same as seen below. How can I modify the Cases to just look at
the first character? For example the Case "R" will now be "R - 1". I want it
to still just look at the R and change the backcolor as specified.

If strCaption = vbNullString Then
.Caption = Day(datStartDate)
.Bold = False
Else
.Caption = strCaption
.Bold = True
Select Case strCaption
Case "R"
.BackColor = vbBlue
Case "U"
.BackColor = vbBlue
Case "N"
.BackColor = vbBlue
Case "A"
.BackColor = vbBlue
Case "P"
.BackColor = 39423
Case Else
.BackColor = vbRed
End Select
.ForeColor = vbWhite
End If
 
D

Dirk Goldgar

Secret Squirrel said:
I'm using the following case select to change the backcolor of some
controls
on my report. My question is how can I use just the first character in my
case selects? I'm going to modify my strCaption but the first value will
still be the same as seen below. How can I modify the Cases to just look
at
the first character? For example the Case "R" will now be "R - 1". I want
it
to still just look at the R and change the backcolor as specified.

If strCaption = vbNullString Then
.Caption = Day(datStartDate)
.Bold = False
Else
.Caption = strCaption
.Bold = True
Select Case strCaption
Case "R"
.BackColor = vbBlue
Case "U"
.BackColor = vbBlue
Case "N"
.BackColor = vbBlue
Case "A"
.BackColor = vbBlue
Case "P"
.BackColor = 39423
Case Else
.BackColor = vbRed
End Select
.ForeColor = vbWhite
End If


Use this:

Select Case Left(strCaption, 1)
 
S

Secret Squirrel

Funny you say that because I was just beginning to modify it just like that.

Thanks!
SS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top