Link to home
Start Free TrialLog in
Avatar of rito1
rito1

asked on

Another Type Mismatch when calling Sub

Hi All

Sorry!.. I have tried looking through solutions that have the keywords Type Mismatch but cannot see anything wrong with my code...

I have the following Subroutine within a seperate file that I include within my page...

Sub ChefMenusNotify(NotifyItem)

      Dim strSQL, objRS
      Dim NotifyDate, StoredDate, RichDate
      
      NotifyDate = Date()
      
      'Chef Menu notification is ID 1 within Nofication_Dates table
      strSQL = "GetNotificationDate " & NotifyItem
      Set objRS = GetRecordset(strSQL)
      
      Do While Not objRS.EOF
            StoredDate = objRS("NextNotifyDate")
            objRS.MoveNext
      Loop
      
      If NotifyDate >= StoredDate Then
      Call SendNotificationMail("web_master@prestoungrange.org","my@mysite.com","you@mysite.com","Menu Update Notification","This is a reminder that the Online Menu needs updating.")
      
      Dim NewDate
      
      NewDate = StoredDate + 7
      
      ExecuteQuery("UpdateNotificationDate " & NotifyItem & ",'" & NewDate & "'")
      
      End IF

      Set objRS = Nothing
End Sub

And then within my Page I call the Sub as follows...

<% Call  ChefMenusNotify(1)%>

The error I get is as follows:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'ChefMenusNotify'

the funny thing is, is if I have the sub within the same page as what I am calling it from and not reference into the page via an include, it seems to work fine??

Does anyone have any ideas?

.. There are a few other Functions/Subs that this Subsroutine uses which I haven't included within this posting as I haven't actually made any changes to these and know they are in good working order.

Many thanks

Rit
Avatar of _Stilgar_
_Stilgar_
Flag of Israel image

Do you include it before the call? also, note the include should not be contained within the <% %> brackets.

Stilgar.
Avatar of rito1
rito1

ASKER

Hi
I do include it before the call and it currently looks like this on the page...

Rit


<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="incUIFunctions.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
<% Call ChefMenusNotify(1) %>
</body>
</html>

Open in new window

> the funny thing is, is if I have the sub within the same page as what I am calling it from and not reference into the page via an include, it seems to work fine??

My guess is that you have two different subs with the same name. If that happens ASP seems to take the last one as the valid function. Maybe you should check the includes you are using for functions of that name.
Avatar of rito1

ASKER

Hi sybe

Thanks fro you input. I have just checked the include and there is only 1 instance of this Sub.

Rit
>>The error I get is as follows:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'ChefMenusNotify'

This is due to passign some null value to the procedure or encountered a end of file. There are several procedures within 'ChefMenusNotify' , check for null values etc.

I added if not eof condition also checking dates with cdate.
Just add soem debuggign code withing the proc liek response.wriet and response.end and follow the Output
Sub ChefMenusNotify(NotifyItem)
 
      Dim strSQL, objRS
      Dim NotifyDate, StoredDate, RichDate
      
      NotifyDate = Date()
      
      'Chef Menu notification is ID 1 within Nofication_Dates table
      strSQL = "GetNotificationDate " & NotifyItem
      Set objRS = GetRecordset(strSQL)
      
If not objRS.eof then
      Do While Not objRS.EOF
            StoredDate = objRS("NextNotifyDate")
            objRS.MoveNext
      Loop
      
      If cDate(NotifyDate) >= CDate(StoredDate) Then
      Call SendNotificationMail("web_master@prestoungrange.org","my@mysite.com","you@mysite.com","Menu Update Notification","This is a reminder that the Online Menu needs updating.")
      
      Dim NewDate
      
      NewDate = StoredDate + 7
      
      ExecuteQuery("UpdateNotificationDate " & NotifyItem & ",'" & NewDate & "'")
      
      End IF
End if
      Set objRS = Nothing
End Sub

Open in new window

@jitganguly I'm not sure you're right. If it was an error within that function he would get an error that referrs to the line within the function.

This error means that either ChefMenusNotify is not recognized (not included after all for some reason), or is being used as a variable, which is of another type.

Can you access any of the functions or variants declared in that file from your code?

Is the sub declared within <% %> brackets in that include file?

I just tested the logic on my end and it works beatifully.

Stilgar.
You might have a variable named "ChefMenusNotify"

The error is consistent with that. The code expects an Array, but the variable isn't an array. Then you get the "type mismatch" error.

NewDate = StoredDate + 7
This line could give a type mismatch
Should be using Dateadd function
Avatar of rito1

ASKER

Thanks all, I will have a fiddle with all of your possibilities and let you know how I get on.

Rit
>>NewDate = StoredDate + 7
This line could give a type mismatch<<
No, this is perfectly valid.  Dates are represented internally as doubles.  The whole part being the date, so it is quite OK to add days to a date variable.
I suggest you to try enclosing the parameter in quotation marks

<% Call ChefMenusNotify("1") %>

Open in new window

Avatar of rito1

ASKER

Would there be a reason that I could not call a Sub from my page when the sub resides within the included file?.. that seems to be the case because as soon as I move the Sub to the same page and still include the remainder of the file it used to reside in as the Sub uses other Function, it seems to work!

 
ASKER CERTIFIED SOLUTION
Avatar of _Stilgar_
_Stilgar_
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial