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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error-Conditional Formatting - VBA Code 1

Status
Not open for further replies.

0212

Technical User
Apr 2, 2003
115
US
Good Evening!

I am trying to format a form through VBA. I am getting a compile error "Compile Error: Case without Select Case". I can't find the problem. I have pasted the code below. I am VBA Tenderfoot, so it probably is a simple mistake. Thanks for your help!

Private Sub Form_Open(Cancel As Integer)
Select Case ([Forms]![FrmTrackRptDatesODR]![RptType])
Case 1
Me.RADue.Visible = True
Me.RAProj.Visible = True
Me.RAComp.Visible = True
If Me.RADue < Date + 30 Then
'Make control background Opaque.
Me.RADue.BackStyle = 1
'Make control back color Yellow.
Me.RADue.BackColor = vbYellow
Else
'Make control background transparent.
Me.RADue.BackStyle = 1
'Make background color red.
If Me.RADue <= Date + 30 Then
Me.RADue.BackColor = vbRed
End If

Case 2
Me.CSPDue.Visible = True
Me.CSPProj.Visible = True
Me.CSPComp.Visible = True
If Me.CSPEFF < Date + 30 Then
'Make control background Opaque.
Me.CSPDue.BackStyle = 1
'Make control back color Yellow.
Me.CSPDue.BackColor = vbYellow
Else
'Make control background transparent.
Me.CSPEFF.BackStyle = 1
'Make background color red.
If Me.CSPEFF <= Date + 30 Then
Me.CSPDue.BackColor = vbRed
End If


Case 3
Me.RAADue.Visible = True
Me.RAAProj.Visible = True
Me.RAAComp.Visible = True
If Me.RAAEXP < Date + 30 Then
'Make control background Opaque.
Me.RAADue.BackStyle = 1
'Make control back color Yellow.
Me.RAADue.BackColor = vbYellow
Else
'Make control background transparent.
Me.RAADue.BackStyle = 1
'Make background color red.
If Me.RAAEXP <= Date + 30 Then
Me.RAADue.BackColor = vbRed
End If
End Select
End Sub
 
Indent your code properly and you'll discover some missing End If ...

Furthermore I suggest the Load event procedure instead of Open.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, PHV!! It probably is too late, but I'm under the gun. I really appreciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top