Results 1 to 5 of 5
  1. #1
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38

    Type mismatch

    What am I doing Wrong?
    With:
    Public strWorkbookName As String
    Public strObjName As String
    Where:
    strWorkbookName = "GO_GLS_OPS_Agent - SGE Complex Manager"
    This:
    strObjName = Mid(strWorkbookName, "-" + 2)
    Causes:
    Run-time error '13':


    Type mismatch
    Also:
    Debug.Print Mid(strWorkbookName, "-" + 2)
    Causes:
    Run-time error '13':
    Type mismatch

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    your mid function is not going to work at all, mid function follows the format

    mid(STRING, STARTPOSITION, ENDPOSITION)

    If you are trying to get a string for everything after the - it would be something more like

    trim(right(strWorkbookName, len(strworkbookname) - (instr(strworkbookname, "-") + 1)))

    assuming there is only one hyphen in the workbook name. If not and you want to pick up from the last hyphen you'd have to use instrrev instead of instr.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Mid function would work with:

    Mid(strWorkbookName, InStr(strWorkbookName,"-") + 2)

    The EndPosition argument is optional.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    I didn't know it would work without an endpoint! learn something new every day.

  5. #5
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38
    Thanks to all.
    The Moderator nailed my omission.
    Thank you.

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

Similar Threads

  1. type mismatch
    By seeker63 in forum Programming
    Replies: 2
    Last Post: 12-05-2013, 02:54 PM
  2. type mismatch
    By Compufreak in forum Access
    Replies: 5
    Last Post: 08-08-2012, 11:00 AM
  3. type mismatch
    By slimjen in forum Forms
    Replies: 21
    Last Post: 07-24-2012, 03:14 PM
  4. Type Mismatch....WHY?!!?
    By jgelpi16 in forum Queries
    Replies: 9
    Last Post: 03-07-2011, 09:18 AM
  5. Type Mismatch
    By Alex Motilal in forum Programming
    Replies: 10
    Last Post: 02-13-2011, 05:42 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