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

Type mismatch

Status
Not open for further replies.

mot98

MIS
Jan 25, 2002
647
0
0
CA
Hi All,
I am attempting to write an ASP page with the following code:

' Main Program to check what action to do
Select Case fromForm
Case varSelect="ADD"
Call fromAdd
Case varSelect="EDIT"
Call fromEdit
Case varSelect="DELETE"
Call fromDelete
Case Else
Call initForm
End Select
%>

Now I have a sub fromAdd form that I am wanting it to go to if ADD is selected.

But everytime I get the following error:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'fromAdd'

/ASS3P1.asp, line 33

Can someone tell me what is going on here?

TIA for any help..

mot98..[peace]

"Where's the beer?"
 
I guess you have variable name as 'fromAdd' and same a sub routine name as 'fromAdd' too, this may cause the problem. ------------------
Freedom is a Right
 
The goat may be correct, try to use this form though:

Select Case varSelect
Case "ADD": fromAdd
Case "EDIT": fromEdit
Case "DELETE": fromDelete
Case Else: initForm
End Select

or

Select Case varSelect
Case "ADD"
fromAdd
Case "EDIT"
fromEdit

... and so on. No need to use "Call". It is good from to indent your code. Also for the type mismatch, check that the variables are returning strings. Write the form or querystring to the screen:

response.write request.form


Jonathan Galpin
 
okay..got the type mismatch problem fixed.

However, now I have another problem..

From my initForm.. I have the users select "add", "delete" or "edit"
then it should move to the proper sub routine depending on what they have choosen.

Again here is the code:

' Main Program to check what action to do
Select Case fromForm
Case varSelect="ADD"
addForm
Case varSelect="EDIT"
editForm
Case varSelect="DELETE"
deleteForm
Case Else
initForm
End Select

The initForm is coded as follows:

Sub initForm
Response.Write &quot;<p>Please choose one of the following options:</p>&quot;
Response.Write &quot;<form method='get' action='ASS3P1.asp'>&quot;
Response.Write &quot;<p><SELECT NAME=varSelect SIZE=1>&quot;
Response.Write &quot;<OPTION VALUE=ADD>ADD</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=DELETE>DELETE</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=EDIT>EDIT</OPTION>&quot;
Response.Write &quot;</SELECT></p>&quot;
Response.Write &quot;<p><input type=submit name=Submit></p>&quot;
Response.Write &quot;<input type=hidden value=varSelect name=fromForm>&quot;
Response.Write &quot;</FORM>&quot;
End sub


But no matter what I choose Add, edit or delete, it always comes back to the init screen. Why is it not jumping to the correct sub routine??

Any help would be great..

Thanks mot98..[peace]

&quot;Where's the beer?&quot;
 
What form value is your fromForm variable requesting?

If it is requesting the value of the fromForm hidden, then the value will always be &quot;varSelect&quot;. You need to request the value of varSelect to get the ADD/EDIT/DELETE values.
 
Reference the form properly try: (in asp server side script)

Select Case request.form(&quot;varSelect&quot;)
Case &quot;ADD&quot;: fromAdd
Case &quot;EDIT&quot;: fromEdit
Case &quot;DELETE&quot;: fromDelete
Case Else: initForm
End Select

If it were client side, try form1.varSelect.value where form1 is your form name.



Jonathan Galpin
 
Thanks guys..I think it is working now.

One more thing though..by default the list box is showing ADD..how do I make it so that it shows nothing to start then will show all 3 when the drop it down?

Thanks,

mot98..[peace]

&quot;Where's the beer?&quot;
 
You can just add a blank <option> tag to the select box, but then you will have to validiate to make sure the user doesn't submit the form without selecting an option.

Sub initForm
Response.Write &quot;<p>Please choose one of the following options:</p>&quot;
Response.Write &quot;<form method='get' action='ASS3P1.asp'>&quot;
Response.Write &quot;<p><SELECT NAME=varSelect SIZE=1>&quot;
Response.Write &quot;<OPTION VALUE=''></OPTION>&quot;
Response.Write &quot;<OPTION VALUE=ADD>ADD</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=DELETE>DELETE</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=EDIT>EDIT</OPTION>&quot;
Response.Write &quot;</SELECT></p>&quot;
Response.Write &quot;<p><input type=submit name=Submit></p>&quot;
Response.Write &quot;<input type=hidden value=varSelect name=fromForm>&quot;
Response.Write &quot;</FORM>&quot;
End sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top