Results 1 to 6 of 6
  1. #1
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Type Mismatch

    I wrote the following function and tried to execute it. However it is showing Error 13 Type Mismatch.

    Public Function MyHeapBudPc(MyHeap As Long) As Double

    MyHeapBudPc = "SELECT Sum(([tblPurchase]![qtyPurchasedPked]+[tblPurchase]![qtyPurchasedLoose]) " & _
    "*GetLintBudgetPC([tblSeasonCenterVtyJunction]![CenterPertaining],[tblSeasonCenterVtyJunction]![VarietyPertaining],DateNo([tblPurchase]![dateOfPurchase]), " & _
    "[tblFactory]![factoryType])) AS PCproduct " & _
    "FROM tblSeasonCenterVtyJunction INNER JOIN (tblFactory INNER JOIN (tblHeap INNER JOIN " & _
    "tblPurchase ON tblHeap.heapID = tblPurchase.heapPrepared) ON tblFactory.factoryID = tblHeap.factoryProcessed) ON " & _
    "tblSeasonCenterVtyJunction.SeasonCentVtyID = tblHeap.HeapRelatedTo " & _
    "WHERE (((tblPurchase.heapPrepared)= & MyHeap))"

    End Function



    Please help

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    What kind of data is held in:
    SeasonCentVtyID, HeapRelatedTo, heapPrepared and MyHeap
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    The & before the myheap last line is wrong.


    Sent from my iPhone using Tapatalk

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You're not even getting that far. You're putting a string into a variable defined as Double (the function itself). Presumably you want to open a recordset on the SQL and return the result.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Thanks pbaldy, yes I am trying to return the result.
    Bob Fitz, all the data held in the fields you have mentioned are Integer.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You'll need to open a recordset on that SQL and return the field that's returned. This should help:

    http://www.baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Type 13 (Type Mismatch) error
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 01-22-2016, 10:01 AM
  2. type mismatch
    By seeker63 in forum Programming
    Replies: 2
    Last Post: 12-05-2013, 02:54 PM
  3. type mismatch
    By Compufreak in forum Access
    Replies: 5
    Last Post: 08-08-2012, 11:00 AM
  4. type mismatch
    By slimjen in forum Forms
    Replies: 21
    Last Post: 07-24-2012, 03:14 PM
  5. Type mismatch
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 08-07-2010, 06:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums