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

Exception Occured error when running case statements

Status
Not open for further replies.

jvet4

Technical User
Jul 24, 2000
54
US
I am running into a problem while trying to run a case statement. Here is a little background. I have a form with 10 checkboxes, all with the same name but different values (values range from 1 to 10). The user can select anywhere from 1-9 of the boxes OR the tenth which is a "none apply." I parse this data and sent it to an Access Database where the values are stored with a common ID (i.e. if the user selects the boxes with values 1,4,7 they are all stored with the same ID).
In addition to this I have a modify form that I want the user to be able to modify checkbox selections. To do this I want to display all the checkboxes AND for the ones that they have selected, I want them to be checked. To do this I have written the following case statements that should (at least in my mind!!!) check these boxes, as well as format them properly.

For MsnID = 1 to 10

Select Case MsnID
Case 1,4,7
If objRS("MissionID") = MsnID then
response.write &quot;<tr><td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot; checked>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td>&quot;

else

response.write &quot;<tr><td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot;>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td>&quot;

end if

Case 2,5,8
If objRS(&quot;MissionID&quot;) = MsnID then
response.write &quot;<td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot; checked>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td>&quot;

else

response.write &quot;<td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot;>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td>&quot;

end if

Case 3,6,9
If objRS(&quot;MissionID&quot;) = MsnID then
response.write &quot;<td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot; checked>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td></tr>&quot;

else

response.write &quot;<td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot;>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td></tr>&quot;

end if

Case 10
If objRS(&quot;MissionID&quot;) = MsnID then
response.write &quot;<tr><td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot; checked>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td></tr>&quot;

else

response.write &quot;<tr><td><INPUT TYPE=checkbox NAME=&quot;&quot;mission&quot;&quot; VALUE=&quot;&quot;MsnID&quot;&quot;>&quot; & objMissionRS(&quot;MissText&quot;) & &quot;</td></tr>&quot;

end if
End Select

The problem I am having is that I am getting an &quot;exception Occured&quot; then I try to run this. The error always references the &quot;If objRS(&quot;MissionID&quot;) = MsnID then&quot; line and it references it in different cases, depending on the number of the boxes selected.

I would greatly appreciate any help that can be offered.

Thanks, Jason
 
In your database &quot;MissionID&quot; is an numeric value (integer,long)? if not try to use int(objRS(&quot;MissionID&quot;))
Hope this helps... ________

George
 
Thanks for the post. All the values in the database are currently numeric fields. Whould it help to change them and try it this way?
 
try to use int(...) and if it wont work try to put them Integer... ________

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top