Persiankitte
09-28-2010, 09:14 AM
Ok...SO I am trying to code dropdowns to populate based on what the selection was in the preious box. I have come accross lots of issues (never used VBA before). The code worked fine until I realized I had more then 25 entries for the last box :banghead: so I wrote an If Then to see if that helped. I can't even test it because now it is saying "Case without Select Case" for the cases after the If, When. I need to get this form into my boss asap.
Heres the code:
Sub OnExitDDListCrime()
Dim oDD As DropDown
Set oDD = ActiveDocument.FormFields("ClassDD").DropDown
'Clear previous list
oDD.ListEntries.Clear
'Repopulate list based on user selection
Select Case ActiveDocument.FormFields("CrimeDD").Result
Case "Robbery"
With oDD.ListEntries
.Add "Firearm"
.Add "Knife/Cutting"
.Add "Oth Dangerous Weapon"
.Add "Hands/Feet/Fists"
End With
Case "Burglary"
With oDD.ListEntries
.Add "Force"
.Add "Attempted Forcible Entry"
.Add "Unforced (Unlawful Entry)"
End With
Case "Assult"
With oDD.ListEntries
.Add "Firearm"
.Add "Knife/Cutting"
.Add "Oth Dangerous Weapon"
.Add "Hands / Feet / Fists"
.Add "No Weapon"
End With
Case "Theft"
With oDD.ListEntries
.Add "Over $400"
.Add "Loss Betw $200-$400"
.Add "Loss Betw $50-$199.99"
.Add "Loss Under $50"
End With
End Select
Set oDD = ActiveDocument.FormFields("TypeDD").DropDown
'Clear previous list
oDD.ListEntries.Clear
'Repopulate list based on user selection
Select Case ActiveDocument.FormFields("CrimeDD").Result
Case "Robbery"
With oDD.ListEntries
.Add "Highway"
.Add "Commercial House"
.Add "Gas/Service Station"
.Add "Convenience Store"
.Add "Residence"
.Add "Bank"
.Add "ATM"
.Add "MISC"
.Add "Carjacking"
End With
Case "Burglary"
With oDD.ListEntries
.Add "Residence Night (6PM-6AM)"
.Add "Residence Day (6AM - 6PM)"
.Add "Residence UNK Time"
.Add "Non-Residence Night (6PM-6AM)"
.Add "Non-Residence Day (6AM - 6PM)"
.Add "Non-Residence UNK Time"
End With
Case "Assult"
With oDD.ListEntries
.Add " "
End With
Case "Theft"
With oDD.ListEntries
.Add "Pick Pocket"
.Add "Purse Snatch"
.Add "Shoplift"
.Add "From Motor Vehicles"
.Add "Motor Veh Parts & Access"
.Add "Bicycles"
.Add "From Building"
.Add "Coin Machines"
.Add "All Others-Includes Theft of Firearms, Regardless of Values"
End With
End Select
Set oDD = ActiveDocument.FormFields("UCRCODEDD").DropDown
'Clear previous list
oDD.ListEntries.Clear
'Repopulate list based on user selection
Select Case ActiveDocument.FormFields("CrimeDD").Result
Case "Robbery"
With oDD.ListEntries
.Add " "
.Add "03-A-13"
.Add "03-A-05"
.Add "03-A-23"
.Add "03-A-07"
.Add "03-A-20"
.Add "03-A-02"
.Add "03-A-25"
.Add "03-B-13"
.Add "03-B-05"
.Add "03-B-23"
.Add "03-B-07"
.Add "03-B-20"
.Add "03-B-02"
.Add "03-B-23"
.Add "03-C-13"
.Add "03-C-05"
.Add "03-C-23"
.Add "03-C-07"
.Add "03-C-20"
.Add "03-C-02"
.Add "03-C-23"
.Add "03-D-13"
.Add "03-D-05"
.Add "03-D-23"
.Add "...Next List..."
If "...Next List..." Then
'Repopulate list based on user selection
With oDD.ListEntries
.Add "03-D-07"
.Add "03-D-20"
.Add "03-D-02"
.Add "03-D-23"
.Add "...Previous List"
End With
Case "Burglary"
With oDD.ListEntries
.Add "05-A-01"
.Add "05-A-02"
.Add "05-A-03"
.Add "05-A-04"
.Add "05-A-05"
.Add "06-A-06"
.Add "05-B-01"
.Add "05-B-02"
.Add "05-B-03"
.Add "05-B-04"
.Add "05-B-05"
.Add "05-B-06"
.Add "05-C-01"
.Add "05-C-02"
.Add "05-C-03"
.Add "05-C-04"
.Add "05-C-05"
.Add "05-C-06"
End With
Case "Assult"
With oDD.ListEntries
.Add "04-A"
.Add "04-B"
.Add "04-C"
.Add "04-D"
.Add "09-E"
End With
Case "Theft"
With oDD.ListEntries
.Add "06-A"
.Add "06-B"
.Add "06-C"
.Add "06-D"
.Add "06-E"
.Add "06-F"
.Add "06-G"
.Add "06-H"
.Add "06-I"
End With
End Select
End Sub
Please Help :help : pray2:
Heres the code:
Sub OnExitDDListCrime()
Dim oDD As DropDown
Set oDD = ActiveDocument.FormFields("ClassDD").DropDown
'Clear previous list
oDD.ListEntries.Clear
'Repopulate list based on user selection
Select Case ActiveDocument.FormFields("CrimeDD").Result
Case "Robbery"
With oDD.ListEntries
.Add "Firearm"
.Add "Knife/Cutting"
.Add "Oth Dangerous Weapon"
.Add "Hands/Feet/Fists"
End With
Case "Burglary"
With oDD.ListEntries
.Add "Force"
.Add "Attempted Forcible Entry"
.Add "Unforced (Unlawful Entry)"
End With
Case "Assult"
With oDD.ListEntries
.Add "Firearm"
.Add "Knife/Cutting"
.Add "Oth Dangerous Weapon"
.Add "Hands / Feet / Fists"
.Add "No Weapon"
End With
Case "Theft"
With oDD.ListEntries
.Add "Over $400"
.Add "Loss Betw $200-$400"
.Add "Loss Betw $50-$199.99"
.Add "Loss Under $50"
End With
End Select
Set oDD = ActiveDocument.FormFields("TypeDD").DropDown
'Clear previous list
oDD.ListEntries.Clear
'Repopulate list based on user selection
Select Case ActiveDocument.FormFields("CrimeDD").Result
Case "Robbery"
With oDD.ListEntries
.Add "Highway"
.Add "Commercial House"
.Add "Gas/Service Station"
.Add "Convenience Store"
.Add "Residence"
.Add "Bank"
.Add "ATM"
.Add "MISC"
.Add "Carjacking"
End With
Case "Burglary"
With oDD.ListEntries
.Add "Residence Night (6PM-6AM)"
.Add "Residence Day (6AM - 6PM)"
.Add "Residence UNK Time"
.Add "Non-Residence Night (6PM-6AM)"
.Add "Non-Residence Day (6AM - 6PM)"
.Add "Non-Residence UNK Time"
End With
Case "Assult"
With oDD.ListEntries
.Add " "
End With
Case "Theft"
With oDD.ListEntries
.Add "Pick Pocket"
.Add "Purse Snatch"
.Add "Shoplift"
.Add "From Motor Vehicles"
.Add "Motor Veh Parts & Access"
.Add "Bicycles"
.Add "From Building"
.Add "Coin Machines"
.Add "All Others-Includes Theft of Firearms, Regardless of Values"
End With
End Select
Set oDD = ActiveDocument.FormFields("UCRCODEDD").DropDown
'Clear previous list
oDD.ListEntries.Clear
'Repopulate list based on user selection
Select Case ActiveDocument.FormFields("CrimeDD").Result
Case "Robbery"
With oDD.ListEntries
.Add " "
.Add "03-A-13"
.Add "03-A-05"
.Add "03-A-23"
.Add "03-A-07"
.Add "03-A-20"
.Add "03-A-02"
.Add "03-A-25"
.Add "03-B-13"
.Add "03-B-05"
.Add "03-B-23"
.Add "03-B-07"
.Add "03-B-20"
.Add "03-B-02"
.Add "03-B-23"
.Add "03-C-13"
.Add "03-C-05"
.Add "03-C-23"
.Add "03-C-07"
.Add "03-C-20"
.Add "03-C-02"
.Add "03-C-23"
.Add "03-D-13"
.Add "03-D-05"
.Add "03-D-23"
.Add "...Next List..."
If "...Next List..." Then
'Repopulate list based on user selection
With oDD.ListEntries
.Add "03-D-07"
.Add "03-D-20"
.Add "03-D-02"
.Add "03-D-23"
.Add "...Previous List"
End With
Case "Burglary"
With oDD.ListEntries
.Add "05-A-01"
.Add "05-A-02"
.Add "05-A-03"
.Add "05-A-04"
.Add "05-A-05"
.Add "06-A-06"
.Add "05-B-01"
.Add "05-B-02"
.Add "05-B-03"
.Add "05-B-04"
.Add "05-B-05"
.Add "05-B-06"
.Add "05-C-01"
.Add "05-C-02"
.Add "05-C-03"
.Add "05-C-04"
.Add "05-C-05"
.Add "05-C-06"
End With
Case "Assult"
With oDD.ListEntries
.Add "04-A"
.Add "04-B"
.Add "04-C"
.Add "04-D"
.Add "09-E"
End With
Case "Theft"
With oDD.ListEntries
.Add "06-A"
.Add "06-B"
.Add "06-C"
.Add "06-D"
.Add "06-E"
.Add "06-F"
.Add "06-G"
.Add "06-H"
.Add "06-I"
End With
End Select
End Sub
Please Help :help : pray2: