[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Another Type Mismatch when calling Sub

Posted on 2007-12-04
13
Medium Priority
?
2,455 Views
Last Modified: 2008-05-20
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
Comment
Question by:rito1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +3
13 Comments
 
LVL 14

Expert Comment

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

Stilgar.
0
 
LVL 1

Author Comment

by:rito1
ID: 20403652
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
 
LVL 28

Expert Comment

by:sybe
ID: 20403655
> 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:rito1
ID: 20403710
Hi sybe

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

Rit
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 20404146
>>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
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 20404611
@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
 
LVL 28

Expert Comment

by:sybe
ID: 20406151
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
 
LVL 20

Expert Comment

by:jitganguly
ID: 20406189
NewDate = StoredDate + 7
This line could give a type mismatch
Should be using Dateadd function
0
 
LVL 1

Author Comment

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

Rit
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 20409201
>>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
 
LVL 4

Expert Comment

by:faikdsd
ID: 20409796
I suggest you to try enclosing the parameter in quotation marks

<% Call ChefMenusNotify("1") %>

Open in new window

0
 
LVL 1

Author Comment

by:rito1
ID: 20410317
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
 
LVL 14

Accepted Solution

by:
_Stilgar_ earned 1500 total points
ID: 20412716
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question