Results 1 to 6 of 6
  1. #1
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480

    So I'm getting Error 13 Type mismatch. Why? Right(Sendkey, SpacePos)

    I have a little ditty below that pulls out the first and last number, seperated by a space. It normally works fine. However, when I pass one thing in, that looks just like all the others... I get Error 13, type mis match.


    Sendkey = "SS7 18" ' Works


    Sendkey = "SS23 19" 'Works
    Sendkey = "SS1 1" 'Works
    Sendkey = "SS1 2" 'Works

    Sendkey = "SS23 8" 'DOES NOT WORK.



    I'm guessing it has something to do with the first number being 2 numbers long and the 2nd number only being one. But the spacepos picks up the space as 3, and thats correct... Any ideas what I'm doing wrong here?

    Code:
    If InStr(Sendkey, "SS") > 0 Then
     Sendkey = VBA.Replace(Sendkey, "SS", "")
     SpacePos = InStr(Sendkey, " ")
     Row = VBA.Left(Sendkey, SpacePos - 1)
     Cols = VBA.Right(Sendkey, SpacePos)    ' I get the error message on this line. 
     Call SS(Row, Cols)
     Sendkey = ""
    End If

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    What is Cols defined as? If it's numeric, you're trying to pass a string to it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Hrmm yea, I have them set as integers...

    Code:
    Dim Row As Integer
    Dim Cols As Integer
    Why would it work most of the time, but not this time?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The others are probably sending a leading space, and Access is okay with trimming that off and giving you the number. In other words for "23 19" the space is in position 3, so you're putting " 19" in the variable. For the failing one, you're putting "3 8". If all you want is the number(s) after the space, I'd use the Mid() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Alright, I'll give it a shot. Thanks for the insight.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem, post back if you get stuck.
    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 error... Please help...
    By craig1988 in forum Modules
    Replies: 5
    Last Post: 10-08-2015, 09:25 AM
  3. Error 13 Type Mismatch
    By jj1 in forum Access
    Replies: 5
    Last Post: 05-21-2014, 12:33 PM
  4. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  5. Replies: 1
    Last Post: 05-11-2012, 10:59 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