I have not worked with Select Case before, but I have a gnarly nested If..then..else statement. I needed to try to do something different. I am working in MS Access 2010.
Description:
I created a form that has several fields on it. A person selects a Visit type (1 or 2)and then How Late (1,2 or 3) based upon the selection in the option group, I need other objects to become visible in the form. I placed it on the AfterUpdate of the last field a person selects How Late.
I came up with this idea after looking at other examples on this site of Select Case. I could get my if then to work, but when I moved it into a Select Case then nothing works. Perhaps this is not the correct way to use Select Case. Any wisdom would be greatly appreciated.
Here is the Code:
Description:
I created a form that has several fields on it. A person selects a Visit type (1 or 2)and then How Late (1,2 or 3) based upon the selection in the option group, I need other objects to become visible in the form. I placed it on the AfterUpdate of the last field a person selects How Late.
I came up with this idea after looking at other examples on this site of Select Case. I could get my if then to work, but when I moved it into a Select Case then nothing works. Perhaps this is not the correct way to use Select Case. Any wisdom would be greatly appreciated.
Here is the Code:
Code:
Private Sub opgHowLate_AfterUpdate()
Select Case Me.opgVisitType.Value And Me.opgHowLate.Value
Case (Me.opgVisitType = "1" And Me.opgHowLate = "1")
Me.ckbFastTrackPaper.Visible = True
Me.lblFastTrackPaper.Visible = True
Me.lblNotes.Visible = True
Me.txtNotes.Visible = True
Case (Me.opgVisitType = "1" And Me.opgHowLate = "2")
Me.ckbEvalShortTreat.Visible = True
Me.lblEvalShortTreat.Visible = True
Me.lblEvalOnly.Visible = True
Me.ckbEvalOnly.Visible = True
Me.lblReschedule.Visible = True
Me.ckbReschedule.Visible = True
Me.lblRescheduleWhen.Visible = True
Me.opgRescheduleWhen.Visible = True
Me.lblRescheduleProvider.Visible = True
Me.opgRescheduleProvider.Visible = True
Case (Me.opgVisitType = "1" And Me.opgHowLate = "3")
Me.lblEvalOnly.Visible = True
Me.ckbEvalOnly.Visible = True
Me.lblReschedule.Visible = True
Me.ckbReschedule.Visible = True
Me.lblRescheduleWhen.Visible = True
Me.opgRescheduleWhen.Visible = True
Me.lblRescheduleProvider.Visible = True
Me.opgRescheduleWhen.Visible = True
Me.lblNotes.Visible = True
Me.txtNotes.Visible = True
Case (Me.opgVisitType = "2" And Me.opgHowLate = "1")
Me.lblShorterVisit.Visible = True
Me.ckbShorterVisit.Visible = True
Me.lblNotes.Visible = True
Me.txtNotes.Visible = True
Case (Me.opgVisitType = "2" And Me.opgHowLate = "2")
Me.lblShorterVisit.Visible = True
Me.ckbShorterVisit.Visible = True
Me.lblReschedule.Visible = True
Me.ckbReschedule.Visible = True
Me.lblRescheduleWhen.Visible = True
Me.opgRescheduleWhen.Visible = True
Me.lblRescheduleProvider.Visible = True
Me.opgRescheduleProvider.Visible = True
Me.lblNotes.Visible = True
Me.txtNotes.Visible = True
Case (Me.opgVisitType = "2" And Me.opgHowLate = "3")
Me.lblShorterVisit.Visible = True
Me.ckbShorterVisit.Visible = True
Me.lblReschedule.Visible = True
Me.ckbReschedule.Visible = True
Me.lblRescheduleWhen.Visible = True
Me.opgRescheduleWhen.Visible = True
Me.lblRescheduleProvider.Visible = True
Me.opgRescheduleProvider.Visible = True
Me.lblNotes.Visible = True
Me.txtNotes.Visible = True
End Select
End Sub
Comment