+ Reply to Thread
Results 1 to 9 of 9

SQL Query in VBA throwing mismatch error

  1. #1
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    SQL Query in VBA throwing mismatch error

    I am getting data type mismatch in criteria error in this code..

    please help

    Please Login or Register  to view this content.
    Last edited by pike; 04-06-2011 at 06:07 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,038

    Re: VBA Query help

    It may help others to help you if you uploaded a sample workbook with some typical data and the code in context.

    You don't say where the error occurs and it cannot be tested without the data and structure of the worksbook/sheets.

    That said,

    Please Login or Register  to view this content.

    only Dim's decilechoice As String; the other variables are type variant. You need to specify each variable individually (although it does not need individual Dim statements)


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re:

    the error is obtained while performing this step

    Please Login or Register  to view this content.
    check the paste sql subroutine below

    Please Login or Register  to view this content.
    Last edited by kishen1912; 04-06-2011 at 06:09 AM.

  4. #4
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: VBA Query help

    i am getting the error at this section

    Please Login or Register  to view this content.

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: VBA Query help

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,038

    Re: VBA Query help

    @kishen1912: please follow Pike's instructions or you will not get any assistance.

    A suitable titke might be "Data mismatch in ADODB Connection"

    Also note that, although you have provided more code, there is nothing to test it with. Please post a workbook.

    I, for one, will not try to generate test data in order to find a fault in your code.

    Regards

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: SQL Query in VBA throwing mismatch error

    Hi kishen1912
    Or even Query data type mismatch in criteria error would help other search for a similar problem
    I change it

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: SQL Query in VBA throwing mismatch error

    Thanks for taking the time to comply with the rule .

  9. #9
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: SQL Query in VBA throwing mismatch error

    hi, kishen1912, your SQL string is wrong, when you use IN you can follow it either by sub select statement or data array separated by coma

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1