G
Guest
I'm trying to code an "option group" and I have run into a problem.
My option group has 3 selections (short, medium, long) where the "short"
option is 90 days or less, the "medium" option is 91 to 180 days, and the
"long" option is 181 days to 365 days. At first I thought I could write it
with a "Select Case" statement but now I think it will require a really long
and nasty "IF" statement instead. My VB6 book is at my office whereas I'm
stuck at home with a severe cold/flu.
I have a "starting date" and a "ending date" for projects, what I'm looking
for is when the user inputs the starting date and the ending date into my
form, then they go to the 'Project Term Length" option group and select
either "short", "medium" or "long" term. Based on the amount of days between
"start" and "ending", when the user selects an option, and if they pick the
wrong one for the amount of days, they get a message stating to select
another option or to select the "correct" option for the amount of days
projected.
Here is the "Case Select" code that I started writing and then decided that
I might should use an "IF, Then" statement instead:
Private Sub ProjectLength_AfterUpdate()
Dim intSelect As Integer
Dim Msg As String
Dim strName As String
Select Case ProjectLength
Case Is = 1
intSelect = 1
If (Me![Date_End] - Me![Date_Start] <= 90) Then
strName = "Short Term"
Else
Case Is = 2
intSelect = 2
If (Me![Date_End] - Me![Date_Start] <= 180) Then
strName = "Medium Term"
Else
Case Is = 3
intSelect = 3
If (Me![Date_End] - Me![Date_Start] > 180) Then
strName = "Long Term"
End If
End Select
End Sub
I would really appreciate if someone could give me an idea as to how to code
this properly.
Thanks
My option group has 3 selections (short, medium, long) where the "short"
option is 90 days or less, the "medium" option is 91 to 180 days, and the
"long" option is 181 days to 365 days. At first I thought I could write it
with a "Select Case" statement but now I think it will require a really long
and nasty "IF" statement instead. My VB6 book is at my office whereas I'm
stuck at home with a severe cold/flu.
I have a "starting date" and a "ending date" for projects, what I'm looking
for is when the user inputs the starting date and the ending date into my
form, then they go to the 'Project Term Length" option group and select
either "short", "medium" or "long" term. Based on the amount of days between
"start" and "ending", when the user selects an option, and if they pick the
wrong one for the amount of days, they get a message stating to select
another option or to select the "correct" option for the amount of days
projected.
Here is the "Case Select" code that I started writing and then decided that
I might should use an "IF, Then" statement instead:
Private Sub ProjectLength_AfterUpdate()
Dim intSelect As Integer
Dim Msg As String
Dim strName As String
Select Case ProjectLength
Case Is = 1
intSelect = 1
If (Me![Date_End] - Me![Date_Start] <= 90) Then
strName = "Short Term"
Else
Case Is = 2
intSelect = 2
If (Me![Date_End] - Me![Date_Start] <= 180) Then
strName = "Medium Term"
Else
Case Is = 3
intSelect = 3
If (Me![Date_End] - Me![Date_Start] > 180) Then
strName = "Long Term"
End If
End Select
End Sub
I would really appreciate if someone could give me an idea as to how to code
this properly.
Thanks