• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2494
  • Last Modified:

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
0
rito1
Asked:
rito1
  • 4
  • 3
  • 2
  • +3
1 Solution
 
_Stilgar_Commented:
Do you include it before the call? also, note the include should not be contained within the <% %> brackets.

Stilgar.
0
 
rito1Author Commented:
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

0
 
sybeCommented:
> 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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
rito1Author Commented:
Hi sybe

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

Rit
0
 
jitgangulyCommented:
>>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

0
 
_Stilgar_Commented:
@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.
0
 
sybeCommented:
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.

0
 
jitgangulyCommented:
NewDate = StoredDate + 7
This line could give a type mismatch
Should be using Dateadd function
0
 
rito1Author Commented:
Thanks all, I will have a fiddle with all of your possibilities and let you know how I get on.

Rit
0
 
Anthony PerkinsCommented:
>>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.
0
 
faikdsdCommented:
I suggest you to try enclosing the parameter in quotation marks

<% Call ChefMenusNotify("1") %>

Open in new window

0
 
rito1Author Commented:
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!

 
0
 
_Stilgar_Commented:
Definately not. The sub is just not included for some reason - either because the include file with the sub is not being included or because the code isn't being interpreted (for example it doesn't reside within <% %> brackets). I have tried to execute a sub using the same logic you have locally and it works fine.

Stilgar.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now