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

Type Mismatch in Subprocedure 1

Status
Not open for further replies.

TheStriker

Programmer
Aug 19, 2002
109
US
Hello,

I am trying to test a field to see if it is valued. If it is not, then display a message box on load and redirect the user to another page but I keep getting the dreaded 'Type Mismatch' error. Here is the code:

<SCRIPT language="VBScript">
<!--
Sub CheckEmail
If (<%If (rsSiteInfo.Fields.Item("ContactEmailAddress").Value)%> ="") Then Msgbox "There is no Contact Email listed for this site. Please enter a Contact Email Address for this Site"
Response.Redirect("SiteInfoEdit.asp")
End If
End Sub
-->
</SCRIPT>

I just can't seem to satisfy this error. Any help is appreciated. Thanks
 
It looks like you're using asp in the vbscript.

Try this:
Code:
If (<%=(rsSiteInfo.Fields.Item("ContactEmailAddress").Value)%> ="")

Hope this helps,

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Hello TheStriker,

Further to TwoOdd's posting, you may need this as well.
Code:
'Response.Redirect("SiteInfoEdit.asp")  'this is server-side only
document.location.href="[URL unfurl="true"]http://abc.def/ghi/SitInfoEdit.asp"[/URL]
regards - tsuji
 
Thanks guys,

That eliminated the Type Mismatch error but now it is not pulling up the MsgBox when that field is empty but it does redirect. I know I have the Msgbox after the Response.Redirect so I moved the Msgbox before the Redirect and still no go. Also, it redirects even when the field is not empty. I'm completely baffled. Any suggestions?

Thanks in advance
Striker
 
TheStriker,

If you use if block, your msgbox line must be on a separate line.
Code:
Sub CheckEmail
   [COLOR=blue]'add this to check what returns and comment out later
    msgbox <%=(rsSiteInfo.Fields.Item("ContactEmailAddress").Value)%>[/color]
If (<%=(rsSiteInfo.Fields.Item("ContactEmailAddress").Value)%> ="") Then
    Msgbox "There is no Contact Email listed for this site.  Please enter a Contact Email Address for this Site"
    <% Response.Redirect("SiteInfoEdit.asp") %>
End If
End Sub
- tsuji
 
tsuji,

Thanks for your reply. This looks about right. I was not differentiating client-side vs. server-side script in my code. I didn't know that ASP code has to be executed on the server side with <%Response.Redirect(url)%> inside the script code block so this may be a big help. I will try this when I get back from the holiday weekend and let you know how it goes. In the meantime, Have a Star!!!

Have a happy and Safe 4th of July.

The Striker
 
Auuugggghh!!

Guys I just tried it again in another subprocedure and the Type Mismatch error came back again. Here is the code:

<script language="VBScript">
sub CheckUPSReq

If (<%=(spUPSReq.Fields.Item("Outlet_Req").Value)%> =False) then
msgbox "You currently do not have adequate voltage to support the UPS unit. Please contact your Field Facilities Coordinator to order an outlet with adequate voltage."
End if
End sub
</script>

I am just trying to check to see if a field has a value of True or False (0 or 1) and Redirect accordingly. Any help is appreciated.

Thanks
TheStriker
 
Auuugggghh!!

Guys I just tried it again in another subprocedure and the Type Mismatch error came back again. Here is the code:

Code:
<script language="VBScript">
sub CheckUPSReq

If (<%=(spUPSReq.Fields.Item("Outlet_Req").Value)%> =False) then
msgbox "You currently do not have adequate voltage to support the UPS unit.  Please contact your Field Facilities Coordinator to order an outlet with adequate voltage."
End if
End sub
</script>
I am just trying to check to see if a field has a value of True or False (0 or 1) and Redirect accordingly. Any help is appreciated.

Thanks
TheStriker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top