Solved

Another Type Mismatch when calling Sub

Posted on 2007-12-04
13
2,368 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
  • 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now