PDA

View Full Version : Set Recordset = Execute Select Statement Causes "Type Mismatch" Error



Mavila
05-12-2021, 09:16 AM
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?

OBP
05-14-2021, 11:11 AM
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/access-x32-vs-x64-compatibility/
and this
https://docs.microsoft.com/en-us/office/client-developer/shared/compatibility-between-the-32-bit-and-64-bit-versions-of-office

Mavila
05-20-2021, 07:48 AM
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.

OBP
05-20-2021, 08:00 AM
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.

Mavila
05-20-2021, 04:27 PM
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

OBP
05-21-2021, 05:14 AM
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.