Consulting

Results 1 to 6 of 6

Thread: Set Recordset = Execute Select Statement Causes "Type Mismatch" Error

  1. #1
    VBAX Contributor
    Joined
    Aug 2012
    Posts
    120
    Location

    Set Recordset = Execute Select Statement Causes "Type Mismatch" Error

    This an Access ADO data retrieval that is in a Word document macro.

    I recently bought a new laptop and I'm moving this old macro over to it. The first problem I had was getting "Type Mismatch" error when using Recordset.RecordCount. In my research, it appeared that I was going from a 32-bit environment to a 64-bit environment and that I needed to download and reference Microsoft ActiveX Data Objects 6.1 Library. I did that and it seems to have fixed that particular problem.

    I'm getting the same error when I execute a Select command as follows:
    Set myRs = conn.Execute(mySelectStmt)
    mySelectStmt = "SELECT [TtlPgHdrTxt], [TtlPgHdrStyle], [CntPgHdrStyle], [FtrStyle] FROM [My Preferences] WHERE " _& "[User Co Nm] = '" & UserCoNm & "'"
    It just Selects some small amount of text from the database reflecting the User's preferences.

    This has worked flawlessly for years, so I'm thinking this has to do with the 32-bit vs 64-bit environment. "Type Mismatch" doesn't make sense because it's all text. There's no different data type involved.

    I've researched this on-line but can't find anything directly addressing this issue.

    Any ideas?

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Did you try creating a Blank Access database on the 64 bit machine and then import everything from the Access 32 bit database?
    This might also help.
    https://www.devhut.net/2017/04/13/ac...compatibility/
    and this
    https://docs.microsoft.com/en-us/off...ions-of-office

  3. #3
    VBAX Contributor
    Joined
    Aug 2012
    Posts
    120
    Location
    What I did was uninstall the 64-bit version of Office and reinstalled the 32-bit version on the new machine. I read somewhere else that the 32-bit version is sufficient for what I'm doing.

    Unfortunately, it still does the same thing.

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Have you set a Reference to Access?
    You could ask a mod. to move this to the Word forum as it is a Word macro.

  5. #5
    VBAX Contributor
    Joined
    Aug 2012
    Posts
    120
    Location
    Yes, there's a reference to Microsoft Access 16.0 Object Library.

    I thought about posting this in the Word forum, but it seems to me to be an Access cross-over issue.

    I don't know what the problem is, obviously. lol

  6. #6
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    OK, take a copy of the word doc complete with macro and try the
    myselectstmt select statement without the Where part of it, because that is the most likely place that a type mismatch error is likely to occur.

Posting Permissions

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