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

Nesting Select Case statements

Status
Not open for further replies.

webcats

Programmer
Apr 24, 2002
60
US
Is there a limit to the number of Select Case statements you can nest? Right now I have this (below)and I'm getting a "Compile error Case without Select Case"


Select Case Status
Case 1
Print
Case 2
Select Case DayOfWeek
Case Monday
Docmd.CancelEvent
End Select
Case 3
Print
Case 4
Select Case stMonth
Case January
Print
Case February
Docmd.CancelEvent
End Select
Case 5
Print
Case 6
Print
Case Else
Print
End Select

Thank for the help.
 
This should be no problem, sometimes the offending code is something else, perhaps a loop with no end statement in the same function etc. You should post the code for the function that this code is in in it's entirety, so I can look at the whole thing to try to help you.

Regards,
gkprogrammer
 
Ok, but it's pretty long. Thanks, here it is:

Private Sub Status_AfterUpdate()
On Error GoTo statusafter_error
Dim rs1 As ADODB.Recordset
Dim stUser
Dim stDate As String
Dim stAction As String
Dim dow As String
stUser = VerifyUser()
stDate = Now()

Set rs1 = New ADODB.Recordset
rs1.Open "tblTracking", Application.CurrentProject.Connection, adOpenKeyset, adLockPessimistic

With rs1

.AddNew

!User = stUser
!actDate = Now()
!Action = "Changed the Status on Record # " & Me.CustomerID & _
" to " & DLookup("status", "tlkpstatus", "sid =" & Me.Status)

.Update

End With
Me.Status_Date = Date
Save = True

Select Case Me.Status

Case 5 'Initial Discussion *****************************
Me.InitDiscuss.Value = Date
Me.Status_Date = Date

Case 7 'Loan Officer Hold *****************************
Me.LO_Hold.Value = Date
Me.Status_Date = Date
Case 10 'Logging *****************************

Me.Log_Date.Value = Date
Me.Status_Date = Date
Me.Location.Value = "Logging"
dow = Weekday(Date)
Select Case dow
Case 2
Me.Sch_Com_Date.Value = DateAdd("d", 10, Date)
Case 3
Me.Sch_Com_Date.Value = DateAdd("d", 14, Date)
Case 4
Me.Sch_Com_Date.Value = DateAdd("d", 13, Date)
Case 5
Me.Sch_Com_Date.Value = DateAdd("d", 14, Date)
Case 6
Me.Sch_Com_Date.Value = DateAdd("d", 13, Date)
Case 1
MsgBox "Wow, working on a Sunday, huh?"
Me.Sch_Com_Date.Value = DateAdd("d", 9, Date)
Case 7
MsgBox "Wow, working on a Saturday, huh?"
Me.Sch_Com_Date.Value = DateAdd("d", 12, Date)
End Select

Case 20 'Officer Underwriting *****************************

If IsNull(Me.Officer_Date) Then
DoCmd.CancelEvent
End
End If
If IsNull(Me.Officer_Date2) Then
Me.Officer_Date2 = Me.Officer_Date
Else
If IsNull(Me.Officer_Date3) Then
Me.Officer_Date3 = Me.Officer_Date2
Else
If IsNull(Me.Officer_Date4) Then
Me.Officer_Date4 = Me.Officer_Date3
End If
End If
End If
Me.Officer_Date.Value = Date
Me.Status_Date = Date

Case 25 'Underwriting *****************************

If IsNull(Me.UW_Date) Then
DoCmd.CancelEvent
End
End If
If IsNull(Me.UW_Date2) Then
Me.UW_Date2 = Me.UW_Date
Else
If IsNull(Me.UW_Date3) Then
Me.UW_Date3 = Me.UW_Date2
Else
If IsNull(Me.UW_Date4) Then
Me.UW_Date4 = Me.UW_Date3
End If
End If
End If

Me.UW_Date.Value = Date
Me.Location.Value = "Underwriting Drawer"
Me.Status_Date = Date

Case 30 'Underwriting-Hold *****************************

If IsNull(Me.UW_Hold_Date) Then
DoCmd.CancelEvent
End
End If
If IsNull(Me.UW_Hold_Date2) Then
Me.UW_Hold_Date2 = Me.UW_Hold_Date
Else
If IsNull(Me.UW_Hold_Date3) Then
Me.UW_Hold_Date3 = Me.UW_Hold_Date2
Else
If IsNull(Me.UW_Hold_Date4) Then
Me.UW_Hold_Date4 = Me.UW_Hold_Date3
End If
End If
End If

Me.UW_Hold_Date.Value = Date
Me.Status_Date = Date
Me.Location.Value = "Underwriting Drawer"
Me.Held = 1
If IsNull(Me.Held_Comments) Then
Me.Held_Comments = ""
End If
oldHCom = Me.Held_Comments
Me.Held_Comments.Enabled = True
Me.Held_Comments.Locked = False
Me.Held_Comments = newHCom
Me.Held_Comments.SetFocus
SendKeys "{F2}"

Case 35 'To L/A for Review *****************************

If IsNull(Me.LA_Review) Then
DoCmd.CancelEvent
End
End If
If IsNull(Me.LA_Review2) Then
Me.LA_Review2 = Me.LA_Review
Else
If IsNull(Me.LA_Review3) Then
Me.LA_Review3 = Me.LA_Review2
Else
If IsNull(Me.LA_Review4) Then
Me.LA_Review4 = Me.LA_Review3
End If
End If
End If

Me.LA_Review.Value = Date
Me.Status_Date = Date

Case 50 'Loan Committee *****************************
If IsNull(Me.Committee_Date) Then
DoCmd.CancelEvent
End
End If
If IsNull(Me.Committee_Date2) Then
Me.Committee_Date2 = Me.Committee_Date
Else
If IsNull(Me.Committee_Date3) Then
Me.Committee_Date3 = Me.Committee_Date2
Else
If IsNull(Me.Committee_Date4) Then
Me.Committee_Date4 = Me.Committee_Date3
End If
End If
End If

dow = Weekday(Date)
Me.Committee_Date.Value = Date
Me.Status_Date = Date
Select Case dow
'for Elite customers, the time frame is 5 business days, 7 for Standard.
'So set the Schedule Committee date accordingly.

Case 2
'Monday
If Me.Stnd_Elte = 1 Then
Me.Sch_Com_Date.Value = DateAdd("W", 5, Date)
Else
Me.Sch_Com_Date.Value = DateAdd("W", 7, Date)
Case 3
'Tuesday
If Me.Stnd_Elte = 1 Then
Me.Sch_Com_Date.Value = DateAdd("W", 4, Date)
Else
Me.Sch_Com_Date.Value = DateAdd("W", 6, Date)
Case 4
'Wednesday
If Me.Stnd_Elte = 1 Then
Me.Sch_Com_Date.Value = DateAdd("W", 4, Date)
Else
Me.Sch_Com_Date.Value = DateAdd("W", 6, Date)
Case 5
'Thursday
If Me.Stnd_Elte = 1 Then
Me.Sch_Com_Date.Value = DateAdd("W", 5, Date)
Else
Me.Sch_Com_Date.Value = DateAdd("W", 7, Date)
Case 6
'Friday
If Me.Stnd_Elte = 1 Then
Me.Sch_Com_Date.Value = DateAdd("W", 4, Date)
Else
Me.Sch_Com_Date.Value = DateAdd("W", 6, Date)
Case 1
'Sunday
MsgBox "Wow, working on a Sunday, huh?"
If Me.Stnd_Elte = 1 Then
Me.Sch_Com_Date.Value = DateAdd("W", 4, Date)
Else
Me.Sch_Com_Date.Value = DateAdd("W", 6, Date)
Case 7
'Saturday
MsgBox "Wow, working on a Saturday, huh?"
If Me.Stnd_Elte = 1 Then
Me.Sch_Com_Date.Value = DateAdd("W", 5, Date)
Else
Me.Sch_Com_Date.Value = DateAdd("W", 7, Date)
End Select

Case 60 'Director's Loan Committee *****************************
If IsNull(Me.DirectorComm) Then
DoCmd.CancelEvent
End
End If
If IsNull(Me.DirectorComm2) Then
Me.DirectorComm2 = Me.DirectorComm
Else
If IsNull(Me.DirectorComm3) Then
Me.DirectorComm3 = Me.DirectorComm2
Else
If IsNull(Me.DirectorComm4) Then
Me.DirectorComm4 = Me.DirectorComm3
End If
End If
End If

Me.DirectorComm.Value = Date
Me.Status_Date = Date

Case 65 'Loan Committee Conditions *****************************
Me.DirectorComm.Value = Date
Me.Status_Date = Date

Case 80 'Approved *****************************
Me.Approved_Date.Value = Date
Me.Status_Date = Date

Case 90 'RE-Appraisal Ordered *****************************
Me.Apprsl_Order.Value = Date
Me.Status_Date = Date
Me.Held = 1

Case 95 'RE-Appraisal Received *****************************
Me.Apprsl_Recd.Value = Date
Me.Status_Date = Date
Me.Held = 2

Case 140 'Doc Prep *****************************
Me.DocPrep_Date.Value = Date
Me.Status_Date = Date

Case 150 'Doc Prep-Draw Conditions *****************************
Me.DocPrep_DC_Date.Value = Date
Me.Status_Date = Date

Case 160 'Docs to Client *****************************
Me.DocsOut_Date.Value = Date
Me.Status_Date = Date

Case 170 'Docs Returned *****************************
Me.DocsRet_Date.Value = Date
Me.Status_Date = Date

Case 180 'Funded *****************************
Me.Funded_Date.Value = Date
Me.Status_Date = Date

Case 200 'On Maturing Note Report *****************************
Me.AppMatLnRpt.Value = Date
Me.Status_Date = Date

Case 205 'File Requested *****************************
Me.FileReq_Date.Value = Date
Me.Status_Date = Date

Case 210 'No Action Required *****************************
Me.NoActionReq.Value = Date
Me.Status_Date = Date

Case 220 'Review to Proceed *****************************
Me.ReviewProceed.Value = Date
Me.Status_Date = Date

Case 230 'Letter Sent *****************************
Me.Ctl1stLetterSent.Value = Date
Me.Status_Date = Date

Case 240 '2nd Letter Sent *****************************
Me.Ctl2ndLetterSent.Value = Date
Me.Status_Date = Date

Case 260 'Loan Officer to Contact *****************************
Me.MoreInfoReq.Value = Date
Me.Status_Date = Date

Case 510 'Boarded *****************************
Me.Boarded_Date.Value = Date
Me.Status_Date = Date

Case 530 'Declined *****************************
Me.Declined_Date.Value = Date
Me.Status_Date = Date

Case 540 'Cancelled/Withdrawn *****************************
Me.CncldWithdrwn_Date.Value = Date
Me.Status_Date = Date

End Select
statusafter_error:
Resume Next
End Sub

Thanks.
 
I noticed that under Case 50, you have another Select Case for the variable dow. There is an If statement for each of the cases for this select case and none of them contain an End If on the end of the statement. Add the End If for each of them and this may solve your problem.

Let me know if this helped.

Regards,
gkprogrammer
 
Never mind... I found the problem. I left out about 7 End if's. Thanks!
 
Thanks gkprogrammer, I saw it too - finally!

Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top